util.d.ts 2.0 KB

1234567891011121314151617181920212223
  1. import type { FsCallbackApi } from './types';
  2. import type * as misc from './types/misc';
  3. import { TEncodingExtended } from '../encoding';
  4. import { Readable } from 'stream';
  5. export declare const isWin: boolean;
  6. export declare function promisify(fs: FsCallbackApi, fn: string, getResult?: (result: any) => any): (...args: any[]) => Promise<any>;
  7. export declare function validateCallback<T>(callback: T): misc.AssertCallback<T>;
  8. export declare function modeToNumber(mode: misc.TMode | undefined, def?: any): number;
  9. export declare function nullCheck(path: any, callback?: any): boolean;
  10. export declare function pathToFilename(path: misc.PathLike): string;
  11. export declare function createError(errorCode: string, func?: string, path?: string, path2?: string, Constructor?: ErrorConstructor): Error;
  12. export declare function genRndStr6(): string;
  13. export declare function flagsToNumber(flags: misc.TFlags | undefined): number;
  14. export declare function isFd(path: any): boolean;
  15. export declare function validateFd(fd: any): void;
  16. export declare function streamToBuffer(stream: Readable): Promise<Buffer>;
  17. export declare function dataToBuffer(data: misc.TData, encoding?: string): Buffer;
  18. export declare const bufToUint8: (buf: Buffer) => Uint8Array;
  19. export declare const getWriteArgs: (fd: number, a?: unknown, b?: unknown, c?: unknown, d?: unknown, e?: unknown) => [fd: number, dataAsStr: boolean, buf: Buffer, offset: number, length: number, position: number | null, callback: (...args: any) => void];
  20. export declare const getWriteSyncArgs: (fd: number, a: string | Buffer | ArrayBufferView | DataView, b?: number, c?: number | BufferEncoding, d?: number | null) => [fd: number, buf: Buffer, offset: number, length?: number, position?: number | null];
  21. export declare function bufferToEncoding(buffer: Buffer, encoding?: TEncodingExtended): misc.TDataOut;
  22. export declare function isReadableStream(stream: any): stream is Readable;
  23. export declare const unixify: (filepath: string, stripTrailing?: boolean) => string;