memdisk
Version:
A library and a CLI to create RAM disk on macOS and Linux.
34 lines (32 loc) • 1.47 kB
TypeScript
type SupportedPlatform = 'darwin' | 'linux';
declare const isSupportedPlatform: (platform: string) => platform is SupportedPlatform;
interface CreateOptions {
/** @default true */
quiet?: boolean;
/** @default false */
throwOnNotSupportedPlatform?: boolean;
/** @default false */
darwinUseHFSPlus?: boolean;
}
interface DestroyOptions extends CreateOptions {
force?: boolean;
}
type ErrorBack<R, E = unknown> = [R] extends [void] ? (err: E) => void : (err: E, result: R) => void;
interface Create {
sync: (name: string, bytes: number, options?: CreateOptions) => string;
async: (name: string, bytes: number, options?: CreateOptions) => Promise<string>;
errback: (name: string, bytes: number, options: CreateOptions | undefined, callback: ErrorBack<string>) => void;
}
declare const create: Create;
declare const createSync: Create['sync'];
declare const createAsync: Create['async'];
interface Destroy {
sync: (root: string, options?: DestroyOptions) => void;
async: (root: string, options?: DestroyOptions) => Promise<void>;
errback: (root: string, options: DestroyOptions | undefined, callback: ErrorBack<void>) => void;
}
declare const destroy: Destroy;
declare const destroySync: Destroy['sync'];
declare const destroyAsync: Destroy['async'];
export { create, createAsync, createSync, destroy, destroyAsync, destroySync, isSupportedPlatform };
export type { CreateOptions, DestroyOptions, SupportedPlatform };