extra-fs
Version:
Useful additions to inbuilt fs module.
1,316 lines (1,282 loc) • 68.9 kB
TypeScript
import { EventEmitter } from 'events';
import { PathLike, OpenMode, Mode, NoParamCallback, ReadPosition, ReadAsyncOptions, ReadVResult, WriteVResult, TimeLike, Stats, BigIntStats, StatOptions, EncodingOption, BufferEncodingOption, PathOrFileDescriptor, ObjectEncodingOptions, WriteFileOptions, MakeDirectoryOptions, Dir, OpenDirOptions, Dirent, RmDirOptions, CopyOptions, RmOptions } from 'fs';
export { BigIntOptions, BigIntStats, BufferEncodingOption, CopyOptions, Dir, Dirent, EncodingOption, FSWatcher, MakeDirectoryOptions, Mode, NoParamCallback, ObjectEncodingOptions, OpenDirOptions, OpenMode, PathLike, PathOrFileDescriptor, ReadAsyncOptions, ReadPosition, ReadStream, ReadSyncOptions, ReadVResult, RmDirOptions, RmOptions, StatOptions, StatSyncFn, StatSyncOptions, StatWatcher, Stats, StatsBase, TimeLike, WatchEventType, WatchFileOptions, WatchListener, WatchOptions, WriteFileOptions, WriteStream, WriteVResult, accessSync, appendFileSync, chmodSync, chownSync, closeSync, constants, copyFileSync, cpSync, createReadStream, createWriteStream, existsSync, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdirSync, mkdtempSync, openSync, opendirSync, readFileSync, readSync, readdirSync, readlinkSync, readvSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, symlinkSync, truncateSync, unlinkSync, unwatchFile, utimesSync, watch, watchFile, writeFileSync, writeSync, writevSync } from 'fs';
import * as P from 'fs/promises';
export { P as promises };
export { access as accessAsync, appendFile as appendFileAsync, chmod as chmodAsync, chown as chownAsync, copyFile as copyFileAsync, cp as cpAsync, lchown as lchownAsync, link as linkAsync, lstat as lstatAsync, lutimes as lutimesAsync, mkdir as mkdirAsync, mkdtemp as mkdtempAsync, open as openAsync, opendir as opendirAsync, readFile as readFileAsync, readdir as readdirAsync, readlink as readlinkAsync, realpath as realpathAsync, rename as renameAsync, rm as rmAsync, rmdir as rmdirAsync, stat as statAsync, symlink as symlinkAsync, truncate as truncateAsync, unlink as unlinkAsync, utimes as utimesAsync, writeFile as writeFileAsync } from 'fs/promises';
/**
* File system error.
* [📘](https://github.com/nodef/extra-fs/wiki/FsError)
*/
declare class FsError extends Error implements NodeJS.ErrnoException {
/** Error code. */
code: string;
constructor(code: string, message: string);
}
/**
* Get results of open().
* [📘](https://github.com/nodef/extra-fs/wiki/OpenCallback)
* @param err open error
* @param fd file descriptor
*/
type OpenCallback = (err: NodeJS.ErrnoException, fd?: number) => void;
/**
* Open a file.
* [📘](https://github.com/nodef/extra-fs/wiki/open)
* @param path file path
* @param callback callback (err, fd)
*/
declare function open(path: PathLike, callback: OpenCallback): void;
/**
* Open a file.
* [📘](https://github.com/nodef/extra-fs/wiki/open)
* @param path file path
* @param flags open flags (r, w, a, x, s, +)
* @param callback callback (err, fd)
*/
declare function open(path: PathLike, flags: OpenMode, callback: OpenCallback): void;
/**
* Open a file.
* [📘](https://github.com/nodef/extra-fs/wiki/open)
* @param path file path
* @param flags open flags (r, w, a, x, s, +)
* @param mode set file mode (permission and sticky bits) [0o666 ⇒ RW]
* @param callback callback (err, fd)
*/
declare function open(path: PathLike, flags: OpenMode, mode: Mode, callback: OpenCallback): void;
/**
* Open a file.
* [📘](https://github.com/nodef/extra-fs/wiki/open)
* @param path file path
* @param flags open flags (r, w, a, x, s, +) [r]
* @param mode set file mode (permission and sticky bits) [0o666 ⇒ RW]
*/
declare function open(path: PathLike, flags?: OpenMode, mode?: Mode): Promise<number>;
/**
* Close a file.
* [📘](https://github.com/nodef/extra-fs/wiki/closeAsync)
* @param fd file descriptor
*/
declare function closeAsync(fd: number): Promise<void>;
/**
* Close a file.
* [📘](https://github.com/nodef/extra-fs/wiki/close)
* @param fd file descriptor
* @param callback callback (err)
*/
declare function close(fd: number, callback: NoParamCallback): void;
/**
* Close a file.
* [📘](https://github.com/nodef/extra-fs/wiki/close)
* @param fd file descriptor
*/
declare function close(fd: number): Promise<void>;
/**
* Results of read().
* [📘](https://github.com/nodef/extra-fs/wiki/ReadResult)
*/
interface ReadResult<B = NodeJS.ArrayBufferView> {
/** Number of bytes read. */
bytesRead: number;
/** Output buffer. */
buffer: B;
}
/**
* Get results of read().
* [📘](https://github.com/nodef/extra-fs/wiki/ReadCallback)
* @param err read error
* @param bytesRead number of bytes read
* @param buffer output buffer
*/
type ReadCallback<B = NodeJS.ArrayBufferView> = (err: NodeJS.ErrnoException, bytesRead?: number, buffer?: B) => void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readAsync)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @returns read status {bytesRead, buffer}
*/
declare function readAsync(fd: number, buffer?: NodeJS.ArrayBufferView, offset?: number, length?: number, position?: ReadPosition | null): Promise<ReadResult>;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readAsync)
* @param fd file descriptor
* @param options read options {buffer, offset, length, position}
* @returns read status {bytesRead, buffer}
*/
declare function readAsync<B extends NodeJS.ArrayBufferView = NodeJS.ArrayBufferView>(fd: number, options?: ReadAsyncOptions<B>): Promise<ReadResult<B>>;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param callback callback (err, bytesRead, buffer)
*/
declare function read(fd: number, callback: ReadCallback): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param callback callback (err, bytesRead, buffer)
*/
declare function read(fd: number, buffer: NodeJS.ArrayBufferView, callback: ReadCallback): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param offset buffer offset [0]
* @param callback callback (err, bytesRead, buffer)
*/
declare function read(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, callback: ReadCallback): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param callback callback (err, bytesRead, buffer)
*/
declare function read(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, callback: ReadCallback): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @param callback callback (err, bytesRead, buffer)
*/
declare function read(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null, callback: ReadCallback): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param options read options {buffer, offset, length, position}
* @param callback callback (err, bytesRead, buffer)
*/
declare function read<B extends NodeJS.ArrayBufferView>(fd: number, options: ReadAsyncOptions<B>, callback: ReadCallback<B>): void;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param buffer output buffer [Buffer.alloc(16384)]
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @returns read status {bytesRead, buffer}
*/
declare function read(fd: number, buffer?: NodeJS.ArrayBufferView, offset?: number, length?: number, position?: ReadPosition | null): Promise<ReadResult>;
/**
* Read data from a file.
* [📘](https://github.com/nodef/extra-fs/wiki/read)
* @param fd file descriptor
* @param options read options {buffer, offset, length, position}
* @returns read status {bytesRead, buffer}
*/
declare function read<B extends NodeJS.ArrayBufferView = NodeJS.ArrayBufferView>(fd: number, options?: ReadAsyncOptions<B>): Promise<ReadResult<B>>;
interface WriteResult<B = NodeJS.ArrayBufferView> {
/** Number of bytes writtem. */
bytesWritten: number;
/** Input buffer. */
buffer: B;
}
/**
* Get results of write().
* [📘](https://github.com/nodef/extra-fs/wiki/WriteCallback)
* @param err write error
* @param bytesWritten number of bytes written
* @param buffer input buffer
*/
type WriteCallback<B = NodeJS.ArrayBufferView> = (err: NodeJS.ErrnoException, bytesWritten?: number, buffer?: B) => void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/writeAsync)
* @param fd file descriptor
* @param buffer input buffer
* @param offset buffer offset [0]
* @param length write length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @returns write status {bytesWritten, buffer}
*/
declare function writeAsync<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, offset?: number, length?: number, position?: number | null): Promise<WriteResult<B>>;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/writeAsync)
* @param fd file descriptor
* @param buffer string data
* @param position file position [null ⇒ current]
* @param encoding string encoding [utf8]
* @returns write status {bytesWritten, buffer}
*/
declare function writeAsync(fd: number, buffer: string, position?: number | null, encoding?: BufferEncoding): Promise<WriteResult<string>>;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer input buffer
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, callback: WriteCallback<B>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer input buffer
* @param offset buffer offset [0]
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, offset: number, callback: WriteCallback<B>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer input buffer
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, offset: number, length: number, callback: WriteCallback<B>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer input buffer
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, offset: number, length: number, position: ReadPosition | null, callback: WriteCallback<B>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer string data
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write(fd: number, buffer: string, callback: WriteCallback<string>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer string data
* @param position file position [null ⇒ current]
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write(fd: number, buffer: string, position: number | null, callback: WriteCallback<string>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer string data
* @param position file position [null ⇒ current]
* @param encoding string encoding [utf8]
* @param callback callback (err, bytesWritten, buffer)
*/
declare function write(fd: number, buffer: string, position: number | null, encoding: BufferEncoding, callback: WriteCallback<string>): void;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer input buffer
* @param offset buffer offset [0]
* @param length read length [buffer.length - offset]
* @param position file position [null ⇒ current]
* @returns write status {bytesWritten, buffer}
*/
declare function write<B extends NodeJS.ArrayBufferView>(fd: number, buffer: B, offset: number, length: number, position: ReadPosition | null): Promise<WriteResult<B>>;
/**
* Write data to a file.
* [📘](https://github.com/nodef/extra-fs/wiki/write)
* @param fd file descriptor
* @param buffer string data
* @param position file position [null ⇒ current]
* @param encoding string encoding [utf8]
* @returns write status {bytesWritten, buffer}
*/
declare function write(fd: number, buffer: string, position?: number | null, encoding?: BufferEncoding): Promise<WriteResult<string>>;
/**
* Get results of readv().
* [📘](https://github.com/nodef/extra-fs/wiki/ReadVCallback)
* @param err readv error
* @param bytesRead number of bytes read
* @param buffers output buffers
*/
type ReadVCallback = (err: NodeJS.ErrnoException, bytesRead?: number, buffers?: NodeJS.ArrayBufferView[]) => void;
/**
* Read an array of buffers from file.
* [📘](https://github.com/nodef/extra-fs/wiki/readvAsync)
* @param fd file descriptior
* @param buffers output buffers
* @param position file position [null ⇒ current]
* @returns readv status {bytesRead, buffers}
*/
declare function readvAsync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number | null): Promise<ReadVResult>;
/**
* Read an array of buffers from file.
* [📘](https://github.com/nodef/extra-fs/wiki/readv)
* @param fd file descriptior
* @param buffers output buffers
* @param callback callback (err, bytesRead, buffers)
*/
declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], callback: ReadVCallback): void;
/**
* Read an array of buffers from file.
* [📘](https://github.com/nodef/extra-fs/wiki/readv)
* @param fd file descriptior
* @param buffers output buffers
* @param position file position [null ⇒ current]
* @param callback callback (err, bytesRead, buffers)
*/
declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position: number, callback: ReadVCallback): void | Promise<ReadVResult>;
/**
* Read an array of buffers from file.
* [📘](https://github.com/nodef/extra-fs/wiki/readv)
* @param fd file descriptior
* @param buffers output buffers
* @param position file position [null ⇒ current]
* @returns readv status {bytesRead, buffers}
*/
declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
/**
* Get results of writev().
* [📘](https://github.com/nodef/extra-fs/wiki/WriteVCallback)
* @param err writev error
* @param bytesWritten number of bytes written
* @param buffers input buffers
*/
type WriteVCallback = (err: NodeJS.ErrnoException, bytesWritten?: number, buffers?: NodeJS.ArrayBufferView[]) => void;
/**
* Write an array of buffers to file.
* [📘](https://github.com/nodef/extra-fs/wiki/writevAsync)
* @param fd file descriptior
* @param buffers input buffers
* @param position file position [null ⇒ current]
* @returns writev status {bytesWritten, buffers}
*/
declare function writevAsync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
/**
* Write an array of buffers to file.
* [📘](https://github.com/nodef/extra-fs/wiki/writev)
* @param fd file descriptior
* @param buffers input buffers
* @param callback callback (err, bytesWritten, buffers)
*/
declare function writev(fd: number, buffers: readonly NodeJS.ArrayBufferView[], callback: WriteVCallback): void;
/**
* Write an array of buffers to file.
* [📘](https://github.com/nodef/extra-fs/wiki/writev)
* @param fd file descriptior
* @param buffers input buffers
* @param position file position [null ⇒ current]
* @param callback callback (err, bytesWritten, buffers)
*/
declare function writev(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position: number, callback: WriteVCallback): void;
/**
* Write an array of buffers to file.
* [📘](https://github.com/nodef/extra-fs/wiki/writev)
* @param fd file descriptior
* @param buffers input buffers
* @param position file position [null ⇒ current]
* @returns writev status {bytesWritten, buffers}
*/
declare function writev(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
/**
* Flush file data to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fdatasyncAsync)
* @param fd file descriptor
*/
declare function fdatasyncAsync(fd: number): Promise<void>;
/**
* Flush file data to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fdatasync)
* @param fd file descriptor
* @param callback callback (err)
*/
declare function fdatasync(fd: number, callback: NoParamCallback): void;
/**
* Flush file data to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fdatasync)
* @param fd file descriptor
*/
declare function fdatasync(fd: number): Promise<void>;
/**
* Flush file data and metadata (inode) to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fsyncAsync)
* @param fd file descriptor
*/
declare function fsyncAsync(fd: number): Promise<void>;
/**
* Flush file data and metadata (inode) to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fsync)
* @param fd file descriptor
* @param callback callback (err)
*/
declare function fsync(fd: number, callback: NoParamCallback): void;
/**
* Flush file data and metadata (inode) to storage.
* [📘](https://github.com/nodef/extra-fs/wiki/fsync)
* @param fd file descriptor
*/
declare function fsync(fd: number): Promise<void>;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/ftruncateAsync)
* @param fd file descriptor
* @param len maximum length of file [0]
*/
declare function ftruncateAsync(fd: number, len?: number): Promise<void>;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/ftruncate)
* @param fd file descriptor
* @param callback callback (err)
*/
declare function ftruncate(fd: number, callback: NoParamCallback): void;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/ftruncate)
* @param fd file descriptor
* @param len maximum length of file
* @param callback callback (err)
*/
declare function ftruncate(fd: number, len: number, callback: NoParamCallback): void;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/ftruncate)
* @param fd file descriptor
* @param len maximum length of file [0]
*/
declare function ftruncate(fd: number, len?: number): Promise<void>;
/**
* Change the file system timestamps of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/futimesAsync)
* @param fd file descriptor
* @param atime last access time
* @param mtime last modified time
*/
declare function futimesAsync(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
/**
* Change the file system timestamps of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/futimes)
* @param fd file descriptor
* @param atime last access time
* @param mtime last modified time
* @param callback callback (err)
*/
declare function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
/**
* Change the file system timestamps of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/futimes)
* @param fd file descriptor
* @param atime last access time
* @param mtime last modified time
*/
declare function futimes(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
/**
* Get results of [f/l]stat().
* [📘](https://github.com/nodef/extra-fs/wiki/StatCallback)
*/
type StatCallback<T = Stats | BigIntStats> = (err: NodeJS.ErrnoException, stats?: T) => void;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstatAsync)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstatAsync(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstatAsync)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstatAsync(fd: number, options: StatOptions & {
bigint?: false;
}): Promise<Stats>;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstatAsync)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstatAsync(fd: number, options: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param callback callback (err, stats)
*/
declare function fstat(fd: number, callback: StatCallback): void;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @param callback callback (err, stats)
*/
declare function fstat(fd: number, options: StatOptions, callback: StatCallback): void;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @param callback callback (err, stats)
*/
declare function fstat(fd: number, options: StatOptions & {
bigint?: false;
}, callback: StatCallback<Stats>): void;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @param callback callback (err, stats)
*/
declare function fstat(fd: number, options: StatOptions & {
bigint: true;
}, callback: StatCallback<BigIntStats>): void;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstat(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstat(fd: number, options: StatOptions & {
bigint?: false;
}): Promise<Stats>;
/**
* Get information about a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fstat)
* @param fd file descriptor
* @param options fstat options
* @returns stats
*/
declare function fstat(fd: number, options: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
/**
* Set the permissions of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchmodAsync)
* @param fd file descriptor
* @param mode permission mode
*/
declare function fchmodAsync(fd: number, mode: Mode): Promise<void>;
/**
* Set the permissions of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchmod)
* @param fd file descriptor
* @param mode permission mode
* @param callback callback (err)
*/
declare function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
/**
* Set the permissions of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchmod)
* @param fd file descriptor
* @param mode permission mode
*/
declare function fchmod(fd: number, mode: Mode): Promise<void>;
/**
* Set the owner of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchownAsync)
* @param fd file descriptor
* @param uid user id
* @param gid group id
*/
declare function fchownAsync(fd: number, uid: number, gid: number): Promise<void>;
/**
* Set the owner of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchown)
* @param fd file descriptor
* @param uid user id
* @param gid group id
* @param callback callback (err)
*/
declare function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
/**
* Set the owner of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/fchown)
* @param fd file descriptor
* @param uid user id
* @param gid group id
*/
declare function fchown(fd: number, uid: number, gid: number): Promise<void>;
/**
* Create a hard link to a file or directory.
* [📘](https://github.com/nodef/extra-fs/wiki/link)
* @param target existing path
* @param path new path
* @param callback callback (err)
*/
declare function link(target: PathLike, path: PathLike, callback: NoParamCallback): void;
/**
* Create a hard link to a file or directory.
* [📘](https://github.com/nodef/extra-fs/wiki/link)
* @param target existing path
* @param path new path
*/
declare function link(target: PathLike, path: PathLike): Promise<void>;
/**
* Symlink type (win32 only).
* [📘](https://github.com/nodef/extra-fs/wiki/SymlinkType)
*/
type SymlinkType = "file" | "dir" | "junction";
/**
* Create a symbolic link to a file or directory.
* [📘](https://github.com/nodef/extra-fs/wiki/symlink)
* @param target target path
* @param path symlink path
* @param callback callback (err)
*/
declare function symlink(target: PathLike, path: PathLike, type: SymlinkType, callback: NoParamCallback): void;
/**
* Create a symbolic link to a file or directory.
* [📘](https://github.com/nodef/extra-fs/wiki/symlink)
* @param target target path
* @param path symlink path
* @param type symlink type (dir, file, junction)
* @param callback callback (err)
*/
declare function symlink(target: PathLike, path: PathLike, type: SymlinkType, callback: NoParamCallback): void;
/**
* Create a symbolic link to a file or directory.
* [📘](https://github.com/nodef/extra-fs/wiki/symlink)
* @param target target path
* @param path symlink path
* @param type symlink type (dir, file, junction)
*/
declare function symlink(target: PathLike, path: PathLike, type?: SymlinkType): Promise<void>;
/**
* Get results of readlink().
* [📘](https://github.com/nodef/extra-fs/wiki/ReadlinkCallback)
* @param err readlink error
* @param linkString path symlink points to
*/
type ReadlinkCallback<T = string | Buffer> = (err: NodeJS.ErrnoException, linkString?: T) => void;
/**
* Read the contents of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/readlink)
* @param path path of symbolic link
* @param callback callback (err, linkString)
*/
declare function readlink(path: PathLike, callback: ReadlinkCallback<string>): void;
/**
* Read the contents of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/readlink)
* @param path path of symbolic link
* @param options encoding option
* @param callback callback (err, linkString)
*/
declare function readlink(path: PathLike, options: EncodingOption, callback: ReadlinkCallback<string>): void;
/**
* Read the contents of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/readlink)
* @param path path of symbolic link
* @param options encoding option
* @param callback callback (err, linkString)
*/
declare function readlink(path: PathLike, options: BufferEncodingOption, callback: ReadlinkCallback<Buffer>): void;
/**
* Read the contents of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/readlink)
* @param path path of symbolic link
* @param options encoding option
*/
declare function readlink(path: PathLike, options?: EncodingOption): Promise<string>;
/**
* Read the contents of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/readlink)
* @param path path of symbolic link
* @param options encoding option
*/
declare function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
/**
* Get results of realpath().
* [📘](https://github.com/nodef/extra-fs/wiki/RealpathCallback)
* @param err realpath error
* @param resolvedPath resolved path
*/
type RealpathCallback<T = string | Buffer> = (err: NodeJS.ErrnoException, resolvedPath?: T) => void;
/**
* Get canonical pathname by resolving ., .. and symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/realpath)
* @param path file or directory path
* @param callback callback (err, resolvedPath)
*/
declare function realpath(path: PathLike, callback: RealpathCallback<string>): void;
/**
* Get canonical pathname by resolving ., .. and symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/realpath)
* @param path file or directory path
* @param options encoding option
* @param callback callback (err, resolvedPath)
*/
declare function realpath(path: PathLike, options: EncodingOption, callback: RealpathCallback<string>): void;
/**
* Get canonical pathname by resolving ., .. and symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/realpath)
* @param path file or directory path
* @param options encoding option
* @param callback callback (err, resolvedPath)
*/
declare function realpath(path: PathLike, options: BufferEncodingOption, callback: RealpathCallback<Buffer>): void;
/**
* Get canonical pathname by resolving ., .. and symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/realpath)
* @param path file or directory path
* @param options encoding option
*/
declare function realpath(path: PathLike, options?: EncodingOption): Promise<string>;
/**
* Get canonical pathname by resolving ., .. and symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/realpath)
* @param path file or directory path
* @param options encoding option
*/
declare function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
/**
* Change the file system timestamps of an object.
* [📘](https://github.com/nodef/extra-fs/wiki/lutimes)
* @param path file path
* @param atime last access time
* @param mtime last modified time
* @param callback callback (err)
*/
declare function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
/**
* Change the file system timestamps of an object.
* [📘](https://github.com/nodef/extra-fs/wiki/lutimes)
* @param path file path
* @param atime last access time
* @param mtime last modified time
*/
declare function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param callback callback (err, stats)
*/
declare function lstat(path: PathLike, callback: StatCallback): void;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options lstat options
* @param callback callback (err, stats)
*/
declare function lstat(path: PathLike, options: StatOptions, callback: StatCallback): void;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options lstat options
* @param callback callback (err, stats)
*/
declare function lstat(path: PathLike, options: StatOptions & {
bigint?: false;
}, callback: StatCallback<Stats>): void;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options lstat options
* @param callback callback (err, stats)
*/
declare function lstat(path: PathLike, options: StatOptions & {
bigint: true;
}, callback: StatCallback<BigIntStats>): void;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options stat options
* @returns stats
*/
declare function lstat(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options stat options
* @returns stats
*/
declare function lstat(path: PathLike, options: StatOptions & {
bigint?: false;
}): Promise<Stats>;
/**
* Get information about a file, without dereferencing symbolic links.
* [📘](https://github.com/nodef/extra-fs/wiki/lstat)
* @param path file path
* @param options stat options
* @returns stats
*/
declare function lstat(path: PathLike, options: StatOptions & {
bigint?: true;
}): Promise<BigIntStats>;
/**
* Set the owner of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/lchown)
* @param path file descriptor
* @param uid user id
* @param gid group id
* @param callback callback (err)
*/
declare function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
/**
* Set the owner of a symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/lchown)
* @param path file descriptor
* @param uid user id
* @param gid group id
*/
declare function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
/**
* Get results of readFile().
* [📘](https://github.com/nodef/extra-fs/wiki/ReadFileCallback)
* @param err error
* @param data contents of file
*/
type ReadFileCallback<T = string | Buffer> = (err: NodeJS.ErrnoException, data?: T) => void;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param callback callback (err, data)
*/
declare function readFile(path: PathOrFileDescriptor, callback: ReadFileCallback<Buffer>): void;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
* @param callback callback (err, data)
*/
declare function readFile(path: PathOrFileDescriptor, options: {
encoding?: null;
flag?: string;
} & EventEmitter.Abortable, callback: ReadFileCallback<Buffer>): void;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
* @param callback callback (err, data)
*/
declare function readFile(path: PathOrFileDescriptor, options: BufferEncoding | ({
encoding: BufferEncoding;
flag?: string;
} & EventEmitter.Abortable), callback: ReadFileCallback<string>): void;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
* @param callback callback (err, data)
*/
declare function readFile(path: PathOrFileDescriptor, options: BufferEncoding | (ObjectEncodingOptions & {
flag?: string;
} & EventEmitter.Abortable), callback: ReadFileCallback): void;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
*/
declare function readFile(path: PathOrFileDescriptor): Promise<Buffer>;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
*/
declare function readFile(path: PathOrFileDescriptor, options: {
encoding?: null;
flag?: string;
} & EventEmitter.Abortable): Promise<Buffer>;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
*/
declare function readFile(path: PathOrFileDescriptor, options: BufferEncoding | ({
encoding: BufferEncoding;
flag?: string;
} & EventEmitter.Abortable)): Promise<string>;
/**
* Read the entire contents of a file.
* [📘](https://github.com/nodef/extra-fs/wiki/readFile)
* @param path directory path
* @param options read file options
*/
declare function readFile(path: PathOrFileDescriptor, options: BufferEncoding | (ObjectEncodingOptions & {
flag?: string;
} & EventEmitter.Abortable)): Promise<string | Buffer>;
/**
* Write data to the file, replace if it already exists.
* [📘](https://github.com/nodef/extra-fs/wiki/writeFile)
* @param file filename or file descriptor
* @param data data to write
* @param fn callback (err)
*/
declare function writeFile(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, fn: NoParamCallback): void;
/**
* Write data to the file, replace if it already exists.
* [📘](https://github.com/nodef/extra-fs/wiki/writeFile)
* @param file filename or file descriptor
* @param data data to write
* @param options options {encoding, mode, flag, signal}
* @param fn callback (err)
*/
declare function writeFile(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, fn: NoParamCallback): void;
/**
* Write data to the file, replace if it already exists.
* [📘](https://github.com/nodef/extra-fs/wiki/writeFile)
* @param file filename or file descriptor
* @param data data to write
* @param options options {encoding, mode, flag, signal}
*/
declare function writeFile(file: PathLike | P.FileHandle, data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | NodeJS.ReadableStream, options?: WriteFileOptions): Promise<void>;
/**
* Append data to a file, create if it does not exist.
* [📘](https://github.com/nodef/extra-fs/wiki/appendFile)
* @param path filename or file descriptor
* @param data string or buffer data
* @param callback callback (err)
*/
declare function appendFile(path: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
/**
* Append data to a file, create if it does not exist.
* [📘](https://github.com/nodef/extra-fs/wiki/appendFile)
* @param path filename or file descriptor
* @param data string or buffer data
* @param options write file options {encoding, mode, flag}
* @param callback callback (err)
*/
declare function appendFile(path: PathOrFileDescriptor, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
/**
* Append data to a file, create if it does not exist.
* [📘](https://github.com/nodef/extra-fs/wiki/appendFile)
* @param path filename or file descriptor
* @param data string or buffer data
* @param options write file options {encoding, mode, flag}
*/
declare function appendFile(path: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/truncate)
* @param path file path
* @param callback callback (err)
*/
declare function truncate(path: PathLike, callback: NoParamCallback): void;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/truncate)
* @param path file path
* @param len maximum length of file
* @param callback callback (err)
*/
declare function truncate(path: PathLike, len: number, callback: NoParamCallback): void;
/**
* Shorten (truncate) a file.
* [📘](https://github.com/nodef/extra-fs/wiki/truncate)
* @param path file path
* @param len maximum length of file [0]
*/
declare function truncate(path: number, len?: number): Promise<void>;
/**
* Remove a file or symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/unlink)
* @param path file path
* @param callback callback (err)
*/
declare function unlink(path: PathLike, callback: NoParamCallback): void;
/**
* Remove a file or symbolic link.
* [📘](https://github.com/nodef/extra-fs/wiki/unlink)
* @param path file path
*/
declare function unlink(path: PathLike): Promise<void>;
/**
* Change the file system timestamps of an object.
* [📘](https://github.com/nodef/extra-fs/wiki/utimes)
* @param path file path
* @param atime last access time
* @param mtime last modified time
* @param callback callback (err)
*/
declare function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
/**
* Change the file system timestamps of an object.
* [📘](https://github.com/nodef/extra-fs/wiki/utimes)
* @param path file path
* @param atime last access time
* @param mtime last modified time
*/
declare function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param callback callback (err, stats)
*/
declare function stat(path: PathLike, callback: StatCallback<Stats>): void;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
* @param callback callback (err, stats)
*/
declare function stat(path: PathLike, options: StatOptions, callback: StatCallback): void;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
* @param callback callback (err, stats)
*/
declare function stat(path: PathLike, options: StatOptions & {
bigint?: false;
}, callback: StatCallback<Stats>): void;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
* @param callback callback (err, stats)
*/
declare function stat(path: PathLike, options: StatOptions & {
bigint: true;
}, callback: StatCallback<BigIntStats>): void;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
*/
declare function stat(path: PathLike): Promise<Stats>;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
*/
declare function stat(path: PathLike, options: StatOptions): Promise<Stats | BigIntStats>;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
*/
declare function stat(path: PathLike, options: StatOptions & {
bigint?: false;
}): Promise<Stats>;
/**
* Get file status.
* [📘](https://github.com/nodef/extra-fs/wiki/stat)
* @param path file path
* @param options stat options
*/
declare function stat(path: PathLike, options: StatOptions & {
bigint: true;
}): Promise<BigIntStats>;
/**
* Copy source file to destination, overwite if exists.
* [📘](https://github.com/nodef/extra-fs/wiki/copyFile)
* @param src source path
* @param dest destination path
* @param callback callback (err)
*/
declare function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
/**
* Copy source file to destination, overwite if exists.
* [📘](https://github.com/nodef/extra-fs/wiki/copyFile)
* @param src source path
* @param dest destination path
* @param mode copy mode (COPYFILE_EXCL, COPYFILE_FICLONE, COPYFILE_FICLONE_FORCE)
* @param callback callback (err)
*/
declare function copyFile(src: PathLike, dest: PathLike, mode: number, callback: NoParamCallback): void;
/**
* Copy source file to destination, overwite if exists.
* [📘](https://github.com/nodef/extra-fs/wiki/copyFile)
* @param src source path
* @param dest destination path
* @param mode copy mode (COPYFILE_EXCL, COPYFILE_FICLONE, COPYFILE_FICLONE_FORCE)
*/
declare function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
/**
* Get results of mkdir().
* [📘](https://github.com/nodef/extra-fs/wiki/MakeDirectoryCallback)
* @param err error
* @param path first directory path created (if any)
*/
type MakeDirectoryCallback = (err: NodeJS.ErrnoException, path?: string) => void;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param callback callback (err, path?)
*/
declare function mkdir(path: PathLike, callback: NoParamCallback): void;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
* @param callback callback (err, path?)
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions, callback: MakeDirectoryCallback): void;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
* @param callback callback (err, path?)
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions & {
recursive?: false;
}, callback: NoParamCallback): void;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
* @param callback callback (err, path?)
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions & {
recursive: true;
}, callback: MakeDirectoryCallback): void;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
*/
declare function mkdir(path: PathLike): Promise<void>;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
* @returns first directory path created (if any)
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions): Promise<void | string>;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions & {
recursive?: false;
}): Promise<void>;
/**
* Create a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdir)
* @param path directory path
* @param options make directory options
* @returns first directory path created (if any)
*/
declare function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions & {
recursive: true;
}, callback: MakeDirectoryCallback): Promise<string>;
/**
* Get results of mkdtemp().
* [📘](https://github.com/nodef/extra-fs/wiki/MakeDirectoryTemporaryCallback)
* @param err error
* @param path created directory path
*/
type MakeDirectoryTemporaryCallback<T = string | Buffer> = (err: NodeJS.ErrnoException, path?: T) => void;
/**
* Create a unique temporary directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdtemp)
* @param prefix directory prefix
* @param callback callback (err, path)
*/
declare function mkdtemp(prefix: string, callback: MakeDirectoryTemporaryCallback<string>): void;
/**
* Create a unique temporary directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdtemp)
* @param prefix directory prefix
* @param options encoding options
* @param callback callback (err, path)
*/
declare function mkdtemp(prefix: string, options: EncodingOption, callback: MakeDirectoryTemporaryCallback<string>): void;
/**
* Create a unique temporary directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdtemp)
* @param prefix directory prefix
* @param options encoding options
* @param callback callback (err, path)
*/
declare function mkdtemp(prefix: string, options: BufferEncodingOption, callback: MakeDirectoryTemporaryCallback<Buffer>): void;
/**
* Create a unique temporary directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdtemp)
* @param prefix directory prefix
* @param options encoding options
*/
declare function mkdtemp(prefix: string, options?: EncodingOption): Promise<string>;
/**
* Create a unique temporary directory.
* [📘](https://github.com/nodef/extra-fs/wiki/mkdtemp)
* @param prefix directory prefix
* @param options encoding options
*/
declare function mkdtemp(prefix: string, options?: BufferEncodingOption): Promise<Buffer>;
/**
* Get results of opendir().
* [📘](https://github.com/nodef/extra-fs/wiki/OpenDirCallback)
* @param err error
* @param dir directory stream
*/
type OpenDirCallback = (err: NodeJS.ErrnoException, dir?: Dir) => void;
/**
* Open a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/opendir)
* @param path directory path
* @param callback callback (err, dir)
*/
declare function opendir(path: PathLike, callback: OpenDirCallback): void;
/**
* Open a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/opendir)
* @param path directory path
* @param options opendir options {encoding, bufferSize}
* @param callback callback (err, dir)
*/
declare function opendir(path: PathLike, options: OpenDirOptions, callback: OpenDirCallback): void;
/**
* Open a directory.
* [📘](https://github.com/nodef/extra-fs/wiki/opendir)
* @param path directory path
* @param options opendir options {encoding, bufferSize}
* @returns directory stream
*/
declare function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
type ReadDirOptions = BufferEncoding | {
/** Buffer encoding. */
encoding: BufferEncoding;
/** Return Dirent? */
withFileTypes?: false;