@beenotung/tslib
Version:
utils library in Typescript
55 lines (54 loc) • 2.38 kB
TypeScript
/// <reference types="node" />
import * as fs from 'fs';
import { Result } from './result';
export declare let copyFile: typeof fs.copyFile.__promisify__;
/** @deprecated use native typing instead */
export declare type readOptions = {
encoding?: string | null;
flag?: string;
} | string | undefined | null;
/**
* resolve :: Buffer
* reject :: NodeJS.ErrnoException
* */
export declare let readFile: typeof fs.readFile.__promisify__;
export declare let writeFile: typeof fs.writeFile.__promisify__;
export declare let readdir: typeof fs.readdir.__promisify__;
export declare let unlink: typeof fs.unlink.__promisify__;
export declare let rename: typeof fs.rename.__promisify__;
/** Does not dereference symbolic links. */
export declare let lstat: typeof fs.lstat.__promisify__;
/** Does dereference symbolic links */
export declare let stat: typeof fs.stat.__promisify__;
export declare let mkdir: typeof fs.mkdir.__promisify__;
export declare let exists: typeof fs.exists.__promisify__;
/**@deprecated*/
export declare function exist(filename: string): Promise<boolean>;
export declare function hasFile(filename: string): Promise<boolean>;
export declare function hasDirectory(filename: string): Promise<boolean>;
/** @deprecated moved to write-stream.ts */
export { writeStream } from './write-stream';
export declare function scanRecursively(args: {
entryPath: string;
onFile?: (filename: string, basename: string) => Result<void>;
onDir?: (dirname: string, basename: string) => Result<void>;
onComplete?: () => Result<void>;
dereferenceSymbolicLinks?: boolean;
skipDir?: (dirname: string, basename: string) => boolean;
}): Promise<void>;
export declare function scanRecursivelySync(args: {
entryPath: string;
onFile?: (filename: string, basename: string) => void;
onDir?: (dirname: string, basename: string) => void;
onComplete?: () => void;
dereferenceSymbolicLinks?: boolean;
skipDir?: (dirname: string, basename: string) => boolean;
}): void;
export declare function readJsonFile(file: string): Promise<any>;
export declare function readJsonFileSync(file: string): any;
export declare type IterateFileByLineOptions = {
encoding?: BufferEncoding;
batchSize?: number;
close?: () => void;
};
export declare function iterateFileByLine(file: string, options?: IterateFileByLineOptions): Generator<string>;