import EventEmitter, { EventMap } from 'bare-events' import Buffer, { BufferEncoding } from 'bare-buffer' import { constants, AppendFileOptions, CpOptions, Dir, MkdirOptions, OpendirOptions, Path, ReadFileOptions, ReadStream, ReadStreamOptions, ReaddirOptions, ReadlinkOptions, RealpathOptions, RmOptions, Stats, Watcher, WatcherOptions, WriteFileOptions, WriteStream, WriteStreamOptions } from '.' export { constants } interface FileHandleEvents extends EventMap { close: [] } interface FileHandle extends EventEmitter, AsyncDisposable { close(): Promise read( buffer: Buffer | ArrayBufferView, offset?: number, len?: number, pos?: number ): Promise readv(buffers: ArrayBufferView[], position?: number): Promise write( data: Buffer | ArrayBufferView, offset?: number, len?: number, pos?: number ): Promise write(data: string, pos?: number, encoding?: BufferEncoding): Promise stat(): Promise chmod(mode: string | number): Promise createReadStream(opts?: ReadStreamOptions): ReadStream createWriteStream(opts?: WriteStreamOptions): WriteStream } declare class FileHandle { private constructor(fd: number) } export function open( filepath: Path, flags?: Flag | number, mode?: string | number ): Promise export function access(filepath: Path, mode?: number): Promise export function appendFile( filepath: Path, data: string | Buffer | ArrayBufferView, opts?: AppendFileOptions ): Promise export function appendFile( filepath: Path, data: string | Buffer | ArrayBufferView, encoding: BufferEncoding ): Promise export function chmod(filepath: Path, mode: string | number): Promise export function copyFile(src: Path, dst: Path, mode?: number): Promise export function cp(src: Path, dst: Path, opts?: CpOptions): Promise export function lstat(filepath: Path): Promise export function mkdir(filepath: Path, opts?: MkdirOptions): Promise export function mkdir(filepath: Path, mode: number): Promise export function opendir( filepath: Path, opts: OpendirOptions & { encoding?: BufferEncoding } ): Promise> export function opendir( filepath: Path, opts: OpendirOptions & { encoding: 'buffer' } ): Promise> export function opendir(filepath: Path, opts: OpendirOptions): Promise export function opendir(filepath: Path, encoding: BufferEncoding): Promise> export function opendir(filepath: Path, encoding: 'buffer'): Promise> export function opendir(filepath: Path, encoding: BufferEncoding | 'buffer'): Promise export function opendir(filepath: Path): Promise> export function readFile( filepath: Path, opts: ReadFileOptions & { encoding: BufferEncoding } ): Promise export function readFile( filepath: Path, opts: ReadFileOptions & { encoding?: 'buffer' } ): Promise export function readFile(filepath: Path, opts: ReadFileOptions): Promise export function readFile(filepath: Path, encoding: BufferEncoding): Promise export function readFile(filepath: Path, encoding: 'buffer'): Promise export function readFile( filepath: Path, encoding?: BufferEncoding | 'buffer' ): Promise export function readFile(filepath: Path): Promise export function readdir( filepath: Path, opts: ReaddirOptions & { encoding?: BufferEncoding } ): Promise[] | string[]> export function readdir( filepath: Path, opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes: true } ): Promise[]> export function readdir( filepath: Path, opts: ReaddirOptions & { encoding?: BufferEncoding; withFileTypes?: false } ): Promise export function readdir( filepath: Path, opts: ReaddirOptions & { encoding: 'buffer' } ): Promise[] | Buffer[]> export function readdir( filepath: Path, opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes: true } ): Promise[]> export function readdir( filepath: Path, opts: ReaddirOptions & { encoding: 'buffer'; withFileTypes?: false } ): Promise export function readdir( filepath: Path, opts: ReaddirOptions & { withFileTypes: true } ): Promise[]> export function readdir( filepath: Path, opts: ReaddirOptions & { withFileTypes?: false } ): Promise export function readdir(filepath: Path, opts: ReaddirOptions): Promise export function readdir(filepath: Path, encoding: BufferEncoding): Promise export function readdir(filepath: Path, encoding: 'buffer'): Promise export function readdir( filepath: Path, encoding: BufferEncoding | 'buffer' ): Promise export function readdir(filepath: Path): Promise export function readlink( filepath: Path, opts: ReadlinkOptions & { encoding?: BufferEncoding } ): Promise export function readlink( filepath: Path, opts: ReadlinkOptions & { encoding: 'buffer' } ): Promise export function readlink(filepath: Path, opts: ReadlinkOptions): Promise export function readlink(filepath: Path, encoding: BufferEncoding): Promise export function readlink(filepath: Path, encoding: 'buffer'): Promise export function readlink( filepath: Path, encoding: BufferEncoding | 'buffer' ): Promise export function readlink(filepath: Path): Promise export function realpath( filepath: Path, opts: RealpathOptions & { encoding?: BufferEncoding } ): Promise export function realpath( filepath: Path, opts: RealpathOptions & { encoding: 'buffer' } ): Promise export function realpath(filepath: Path, opts: RealpathOptions): Promise export function realpath(filepath: Path, encoding: BufferEncoding): Promise export function realpath(filepath: Path, encoding: 'buffer'): Promise export function realpath( filepath: Path, encoding: BufferEncoding | 'buffer' ): Promise export function realpath(filepath: Path): Promise export function rename(src: Path, dst: Path): Promise export function rm(filepath: Path, opts?: RmOptions): Promise export function rmdir(filepath: Path): Promise export function stat(filepath: Path): Promise export function symlink(target: Path, filepath: Path, type?: string | number): Promise export function unlink(filepath: Path): Promise export function watch( filepath: Path, opts: WatcherOptions & { encoding?: BufferEncoding } ): Watcher export function watch( filepath: Path, opts: WatcherOptions & { encoding: 'buffer' } ): Watcher export function watch(filepath: Path, opts: WatcherOptions): Watcher export function watch(filepath: Path, encoding: BufferEncoding): Watcher export function watch(filepath: Path, encoding: 'buffer'): Watcher export function watch(filepath: Path, encoding: BufferEncoding | 'buffer'): Watcher export function watch(filepath: Path): Watcher export function writeFile( filepath: Path, data: string | Buffer | ArrayBufferView, opts?: WriteFileOptions ): Promise export function writeFile( filepath: Path, data: string | Buffer | ArrayBufferView, encoding: BufferEncoding ): Promise