diff --git a/types/node/fs.d.ts b/types/node/fs.d.ts
index f0ae01b17c..140dd08149 100644
--- a/types/node/fs.d.ts
+++ b/types/node/fs.d.ts
@@ -1,33 +1,2156 @@
-// tslint:disable-next-line:no-bad-reference
-///
+declare module "fs" {
+ import * as stream from "stream";
+ import * as events from "events";
+ import { URL } from "url";
+ import * as promises from 'fs/promises';
-declare module 'fs' {
- interface BigIntStats extends StatsBase {
+ export { promises };
+ /**
+ * Valid types for path values in "fs".
+ */
+ export type PathLike = string | Buffer | URL;
+
+ export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
+
+ export type BufferEncodingOption = 'buffer' | { encoding: 'buffer' };
+
+ export interface BaseEncodingOptions {
+ encoding?: BufferEncoding | null;
}
- class BigIntStats {
+ export type OpenMode = number | string;
+
+ export type Mode = number | string;
+
+ export interface StatsBase {
+ isFile(): boolean;
+ isDirectory(): boolean;
+ isBlockDevice(): boolean;
+ isCharacterDevice(): boolean;
+ isSymbolicLink(): boolean;
+ isFIFO(): boolean;
+ isSocket(): boolean;
+
+ dev: T;
+ ino: T;
+ mode: T;
+ nlink: T;
+ uid: T;
+ gid: T;
+ rdev: T;
+ size: T;
+ blksize: T;
+ blocks: T;
+ atimeMs: T;
+ mtimeMs: T;
+ ctimeMs: T;
+ birthtimeMs: T;
+ atime: Date;
+ mtime: Date;
+ ctime: Date;
+ birthtime: Date;
+ }
+
+ export interface Stats extends StatsBase {
+ }
+
+ export class Stats {
+ }
+
+ export class Dirent {
+ isFile(): boolean;
+ isDirectory(): boolean;
+ isBlockDevice(): boolean;
+ isCharacterDevice(): boolean;
+ isSymbolicLink(): boolean;
+ isFIFO(): boolean;
+ isSocket(): boolean;
+ name: string;
+ }
+
+ /**
+ * A class representing a directory stream.
+ */
+ export class Dir {
+ readonly path: string;
+
+ /**
+ * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
+ */
+ [Symbol.asyncIterator](): AsyncIterableIterator;
+
+ /**
+ * Asynchronously close the directory's underlying resource handle.
+ * Subsequent reads will result in errors.
+ */
+ close(): Promise;
+ close(cb: NoParamCallback): void;
+
+ /**
+ * Synchronously close the directory's underlying resource handle.
+ * Subsequent reads will result in errors.
+ */
+ closeSync(): void;
+
+ /**
+ * Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
+ * After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.
+ * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
+ */
+ read(): Promise;
+ read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
+
+ /**
+ * Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
+ * If there are no more directory entries to read, null will be returned.
+ * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
+ */
+ readSync(): Dirent;
+ }
+
+ export interface FSWatcher extends events.EventEmitter {
+ close(): void;
+
+ /**
+ * events.EventEmitter
+ * 1. change
+ * 2. error
+ */
+ addListener(event: string, listener: (...args: any[]) => void): this;
+ addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
+ addListener(event: "error", listener: (error: Error) => void): this;
+ addListener(event: "close", listener: () => void): this;
+
+ on(event: string, listener: (...args: any[]) => void): this;
+ on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
+ on(event: "error", listener: (error: Error) => void): this;
+ on(event: "close", listener: () => void): this;
+
+ once(event: string, listener: (...args: any[]) => void): this;
+ once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
+ once(event: "error", listener: (error: Error) => void): this;
+ once(event: "close", listener: () => void): this;
+
+ prependListener(event: string, listener: (...args: any[]) => void): this;
+ prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
+ prependListener(event: "error", listener: (error: Error) => void): this;
+ prependListener(event: "close", listener: () => void): this;
+
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
+ prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
+ prependOnceListener(event: "close", listener: () => void): this;
+ }
+
+ export class ReadStream extends stream.Readable {
+ close(): void;
+ bytesRead: number;
+ path: string | Buffer;
+ pending: boolean;
+
+ /**
+ * events.EventEmitter
+ * 1. open
+ * 2. close
+ * 3. ready
+ */
+ addListener(event: "close", listener: () => void): this;
+ addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
+ addListener(event: "end", listener: () => void): this;
+ addListener(event: "error", listener: (err: Error) => void): this;
+ addListener(event: "open", listener: (fd: number) => void): this;
+ addListener(event: "pause", listener: () => void): this;
+ addListener(event: "readable", listener: () => void): this;
+ addListener(event: "ready", listener: () => void): this;
+ addListener(event: "resume", listener: () => void): this;
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ on(event: "close", listener: () => void): this;
+ on(event: "data", listener: (chunk: Buffer | string) => void): this;
+ on(event: "end", listener: () => void): this;
+ on(event: "error", listener: (err: Error) => void): this;
+ on(event: "open", listener: (fd: number) => void): this;
+ on(event: "pause", listener: () => void): this;
+ on(event: "readable", listener: () => void): this;
+ on(event: "ready", listener: () => void): this;
+ on(event: "resume", listener: () => void): this;
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ once(event: "close", listener: () => void): this;
+ once(event: "data", listener: (chunk: Buffer | string) => void): this;
+ once(event: "end", listener: () => void): this;
+ once(event: "error", listener: (err: Error) => void): this;
+ once(event: "open", listener: (fd: number) => void): this;
+ once(event: "pause", listener: () => void): this;
+ once(event: "readable", listener: () => void): this;
+ once(event: "ready", listener: () => void): this;
+ once(event: "resume", listener: () => void): this;
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ prependListener(event: "close", listener: () => void): this;
+ prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
+ prependListener(event: "end", listener: () => void): this;
+ prependListener(event: "error", listener: (err: Error) => void): this;
+ prependListener(event: "open", listener: (fd: number) => void): this;
+ prependListener(event: "pause", listener: () => void): this;
+ prependListener(event: "readable", listener: () => void): this;
+ prependListener(event: "ready", listener: () => void): this;
+ prependListener(event: "resume", listener: () => void): this;
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ prependOnceListener(event: "close", listener: () => void): this;
+ prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
+ prependOnceListener(event: "end", listener: () => void): this;
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
+ prependOnceListener(event: "open", listener: (fd: number) => void): this;
+ prependOnceListener(event: "pause", listener: () => void): this;
+ prependOnceListener(event: "readable", listener: () => void): this;
+ prependOnceListener(event: "ready", listener: () => void): this;
+ prependOnceListener(event: "resume", listener: () => void): this;
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
+ }
+
+ export class WriteStream extends stream.Writable {
+ close(): void;
+ bytesWritten: number;
+ path: string | Buffer;
+ pending: boolean;
+
+ /**
+ * events.EventEmitter
+ * 1. open
+ * 2. close
+ * 3. ready
+ */
+ addListener(event: "close", listener: () => void): this;
+ addListener(event: "drain", listener: () => void): this;
+ addListener(event: "error", listener: (err: Error) => void): this;
+ addListener(event: "finish", listener: () => void): this;
+ addListener(event: "open", listener: (fd: number) => void): this;
+ addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
+ addListener(event: "ready", listener: () => void): this;
+ addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ on(event: "close", listener: () => void): this;
+ on(event: "drain", listener: () => void): this;
+ on(event: "error", listener: (err: Error) => void): this;
+ on(event: "finish", listener: () => void): this;
+ on(event: "open", listener: (fd: number) => void): this;
+ on(event: "pipe", listener: (src: stream.Readable) => void): this;
+ on(event: "ready", listener: () => void): this;
+ on(event: "unpipe", listener: (src: stream.Readable) => void): this;
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ once(event: "close", listener: () => void): this;
+ once(event: "drain", listener: () => void): this;
+ once(event: "error", listener: (err: Error) => void): this;
+ once(event: "finish", listener: () => void): this;
+ once(event: "open", listener: (fd: number) => void): this;
+ once(event: "pipe", listener: (src: stream.Readable) => void): this;
+ once(event: "ready", listener: () => void): this;
+ once(event: "unpipe", listener: (src: stream.Readable) => void): this;
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ prependListener(event: "close", listener: () => void): this;
+ prependListener(event: "drain", listener: () => void): this;
+ prependListener(event: "error", listener: (err: Error) => void): this;
+ prependListener(event: "finish", listener: () => void): this;
+ prependListener(event: "open", listener: (fd: number) => void): this;
+ prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
+ prependListener(event: "ready", listener: () => void): this;
+ prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ prependOnceListener(event: "close", listener: () => void): this;
+ prependOnceListener(event: "drain", listener: () => void): this;
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
+ prependOnceListener(event: "finish", listener: () => void): this;
+ prependOnceListener(event: "open", listener: (fd: number) => void): this;
+ prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
+ prependOnceListener(event: "ready", listener: () => void): this;
+ prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
+ }
+
+ /**
+ * Asynchronous rename(2) - Change the name or location of a file or directory.
+ * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace rename {
+ /**
+ * Asynchronous rename(2) - Change the name or location of a file or directory.
+ * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ function __promisify__(oldPath: PathLike, newPath: PathLike): Promise;
+ }
+
+ /**
+ * Synchronous rename(2) - Change the name or location of a file or directory.
+ * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function renameSync(oldPath: PathLike, newPath: PathLike): void;
+
+ /**
+ * Asynchronous truncate(2) - Truncate a file to a specified length.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param len If not specified, defaults to `0`.
+ */
+ export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronous truncate(2) - Truncate a file to a specified length.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function truncate(path: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace truncate {
+ /**
+ * Asynchronous truncate(2) - Truncate a file to a specified length.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param len If not specified, defaults to `0`.
+ */
+ function __promisify__(path: PathLike, len?: number | null): Promise;
+ }
+
+ /**
+ * Synchronous truncate(2) - Truncate a file to a specified length.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param len If not specified, defaults to `0`.
+ */
+ export function truncateSync(path: PathLike, len?: number | null): void;
+
+ /**
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
+ * @param fd A file descriptor.
+ * @param len If not specified, defaults to `0`.
+ */
+ export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
+ * @param fd A file descriptor.
+ */
+ export function ftruncate(fd: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace ftruncate {
+ /**
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
+ * @param fd A file descriptor.
+ * @param len If not specified, defaults to `0`.
+ */
+ function __promisify__(fd: number, len?: number | null): Promise;
+ }
+
+ /**
+ * Synchronous ftruncate(2) - Truncate a file to a specified length.
+ * @param fd A file descriptor.
+ * @param len If not specified, defaults to `0`.
+ */
+ export function ftruncateSync(fd: number, len?: number | null): void;
+
+ /**
+ * Asynchronous chown(2) - Change ownership of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace chown {
+ /**
+ * Asynchronous chown(2) - Change ownership of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike, uid: number, gid: number): Promise;
+ }
+
+ /**
+ * Synchronous chown(2) - Change ownership of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function chownSync(path: PathLike, uid: number, gid: number): void;
+
+ /**
+ * Asynchronous fchown(2) - Change ownership of a file.
+ * @param fd A file descriptor.
+ */
+ export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace fchown {
+ /**
+ * Asynchronous fchown(2) - Change ownership of a file.
+ * @param fd A file descriptor.
+ */
+ function __promisify__(fd: number, uid: number, gid: number): Promise;
+ }
+
+ /**
+ * Synchronous fchown(2) - Change ownership of a file.
+ * @param fd A file descriptor.
+ */
+ export function fchownSync(fd: number, uid: number, gid: number): void;
+
+ /**
+ * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace lchown {
+ /**
+ * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike, uid: number, gid: number): Promise;
+ }
+
+ /**
+ * Synchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function lchownSync(path: PathLike, uid: number, gid: number): void;
+
+ /**
+ * Asynchronous chmod(2) - Change permissions of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace chmod {
+ /**
+ * Asynchronous chmod(2) - Change permissions of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ function __promisify__(path: PathLike, mode: Mode): Promise;
+ }
+
+ /**
+ * Synchronous chmod(2) - Change permissions of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function chmodSync(path: PathLike, mode: Mode): void;
+
+ /**
+ * Asynchronous fchmod(2) - Change permissions of a file.
+ * @param fd A file descriptor.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace fchmod {
+ /**
+ * Asynchronous fchmod(2) - Change permissions of a file.
+ * @param fd A file descriptor.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ function __promisify__(fd: number, mode: Mode): Promise;
+ }
+
+ /**
+ * Synchronous fchmod(2) - Change permissions of a file.
+ * @param fd A file descriptor.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function fchmodSync(fd: number, mode: Mode): void;
+
+ /**
+ * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace lchmod {
+ /**
+ * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ function __promisify__(path: PathLike, mode: Mode): Promise;
+ }
+
+ /**
+ * Synchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
+ */
+ export function lchmodSync(path: PathLike, mode: Mode): void;
+
+ /**
+ * Asynchronous stat(2) - Get file status.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function stat(path: PathLike, options: BigIntOptions, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
+ export function stat(path: PathLike, options: StatOptions, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
+ export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace stat {
+ /**
+ * Asynchronous stat(2) - Get file status.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike, options: BigIntOptions): Promise;
+ function __promisify__(path: PathLike, options: StatOptions): Promise;
+ function __promisify__(path: PathLike): Promise;
+ }
+
+ /**
+ * Synchronous stat(2) - Get file status.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function statSync(path: PathLike, options: BigIntOptions): BigIntStats;
+ export function statSync(path: PathLike, options: StatOptions): Stats | BigIntStats;
+ export function statSync(path: PathLike): Stats;
+
+ /**
+ * Asynchronous fstat(2) - Get file status.
+ * @param fd A file descriptor.
+ */
+ export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace fstat {
+ /**
+ * Asynchronous fstat(2) - Get file status.
+ * @param fd A file descriptor.
+ */
+ function __promisify__(fd: number): Promise;
+ }
+
+ /**
+ * Synchronous fstat(2) - Get file status.
+ * @param fd A file descriptor.
+ */
+ export function fstatSync(fd: number): Stats;
+
+ /**
+ * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace lstat {
+ /**
+ * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike): Promise;
+ }
+
+ /**
+ * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function lstatSync(path: PathLike): Stats;
+
+ /**
+ * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
+ * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace link {
+ /**
+ * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
+ * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(existingPath: PathLike, newPath: PathLike): Promise;
+ }
+
+ /**
+ * Synchronous link(2) - Create a new link (also known as a hard link) to an existing file.
+ * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function linkSync(existingPath: PathLike, newPath: PathLike): void;
+
+ /**
+ * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
+ * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
+ * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
+ */
+ export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace symlink {
+ /**
+ * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
+ * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
+ * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
+ */
+ function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise;
+
+ type Type = "dir" | "file" | "junction";
+ }
+
+ /**
+ * Synchronous symlink(2) - Create a new symbolic link to an existing file.
+ * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
+ * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
+ * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
+ * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
+ */
+ export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlink(
+ path: PathLike,
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
+ ): void;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlink(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace readlink {
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise;
+
+ /**
+ * Asynchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise;
+ }
+
+ /**
+ * Synchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
+
+ /**
+ * Synchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
+
+ /**
+ * Synchronous readlink(2) - read value of a symbolic link.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpath(
+ path: PathLike,
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
+ ): void;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpath(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace realpath {
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise;
+
+ /**
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise;
+
+ function native(
+ path: PathLike,
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
+ ): void;
+ function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
+ function native(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
+ function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
+ }
+
+ /**
+ * Synchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
+
+ /**
+ * Synchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
+
+ /**
+ * Synchronous realpath(3) - return the canonicalized absolute pathname.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function realpathSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
+
+ export namespace realpathSync {
+ function native(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
+ function native(path: PathLike, options: BufferEncodingOption): Buffer;
+ function native(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
+ }
+
+ /**
+ * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function unlink(path: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace unlink {
+ /**
+ * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike): Promise;
+ }
+
+ /**
+ * Synchronous unlink(2) - delete a name and possibly the file it refers to.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function unlinkSync(path: PathLike): void;
+
+ export interface RmDirOptions {
+ /**
+ * If `true`, perform a recursive directory removal. In
+ * recursive mode, errors are not reported if `path` does not exist, and
+ * operations are retried on failure.
+ * @experimental
+ * @default false
+ */
+ recursive?: boolean;
+ }
+
+ export interface RmDirAsyncOptions extends RmDirOptions {
+ /**
+ * The amount of time in milliseconds to wait between retries.
+ * This option is ignored if the `recursive` option is not `true`.
+ * @default 100
+ */
+ retryDelay?: number;
+ /**
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
+ * number of retries. This option is ignored if the `recursive` option is not
+ * `true`.
+ * @default 0
+ */
+ maxRetries?: number;
+ }
+
+ /**
+ * Asynchronous rmdir(2) - delete a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function rmdir(path: PathLike, callback: NoParamCallback): void;
+ export function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace rmdir {
+ /**
+ * Asynchronous rmdir(2) - delete a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise;
+ }
+
+ /**
+ * Synchronous rmdir(2) - delete a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
+
+ export interface MakeDirectoryOptions {
+ /**
+ * Indicates whether parent folders should be created.
+ * If a folder was created, the path to the first created folder will be returned.
+ * @default false
+ */
+ recursive?: boolean;
+ /**
+ * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
+ * @default 0o777
+ */
+ mode?: Mode;
+ }
+
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path: string) => void): void;
+
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path: string | undefined) => void): void;
+
+ /**
+ * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function mkdir(path: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace mkdir {
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise;
+
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise;
+
+ /**
+ * Asynchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise;
+ }
+
+ /**
+ * Synchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string;
+
+ /**
+ * Synchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
+
+ /**
+ * Synchronous mkdir(2) - create a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
+ */
+ export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtemp(prefix: string, options: BaseEncodingOptions | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtemp(prefix: string, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ */
+ export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace mkdtemp {
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(prefix: string, options: BufferEncodingOption): Promise;
+
+ /**
+ * Asynchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise;
+ }
+
+ /**
+ * Synchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string;
+
+ /**
+ * Synchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
+
+ /**
+ * Synchronously creates a unique temporary directory.
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdir(
+ path: PathLike,
+ options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
+ ): void;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdir(
+ path: PathLike,
+ options: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
+ ): void;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
+ */
+ export function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace readdir {
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false }): Promise;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): Promise;
+
+ /**
+ * Asynchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
+ */
+ function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise;
+ }
+
+ /**
+ * Synchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
+
+ /**
+ * Synchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
+
+ /**
+ * Synchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
+ */
+ export function readdirSync(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): string[] | Buffer[];
+
+ /**
+ * Synchronous readdir(3) - read a directory.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
+ */
+ export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[];
+
+ /**
+ * Asynchronous close(2) - close a file descriptor.
+ * @param fd A file descriptor.
+ */
+ export function close(fd: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace close {
+ /**
+ * Asynchronous close(2) - close a file descriptor.
+ * @param fd A file descriptor.
+ */
+ function __promisify__(fd: number): Promise;
+ }
+
+ /**
+ * Synchronous close(2) - close a file descriptor.
+ * @param fd A file descriptor.
+ */
+ export function closeSync(fd: number): void;
+
+ /**
+ * Asynchronous open(2) - open and possibly create a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
+ */
+ export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
+
+ /**
+ * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ */
+ export function open(path: PathLike, flags: OpenMode, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace open {
+ /**
+ * Asynchronous open(2) - open and possibly create a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
+ */
+ function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise;
+ }
+
+ /**
+ * Synchronous open(2) - open and possibly create a file, returning a file descriptor..
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
+ */
+ export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
+
+ /**
+ * Asynchronously change file timestamps of the file referenced by the supplied path.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace utimes {
+ /**
+ * Asynchronously change file timestamps of the file referenced by the supplied path.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise;
+ }
+
+ /**
+ * Synchronously change file timestamps of the file referenced by the supplied path.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
+
+ /**
+ * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace futimes {
+ /**
+ * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise;
+ }
+
+ /**
+ * Synchronously change file timestamps of the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
+ */
+ export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
+
+ /**
+ * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
+ * @param fd A file descriptor.
+ */
+ export function fsync(fd: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace fsync {
+ /**
+ * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
+ * @param fd A file descriptor.
+ */
+ function __promisify__(fd: number): Promise;
+ }
+
+ /**
+ * Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
+ * @param fd A file descriptor.
+ */
+ export function fsyncSync(fd: number): void;
+
+ /**
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ */
+ export function write(
+ fd: number,
+ buffer: TBuffer,
+ offset: number | undefined | null,
+ length: number | undefined | null,
+ position: number | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
+ ): void;
+
+ /**
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
+ */
+ export function write(
+ fd: number,
+ buffer: TBuffer,
+ offset: number | undefined | null,
+ length: number | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
+ ): void;
+
+ /**
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
+ */
+ export function write(
+ fd: number,
+ buffer: TBuffer,
+ offset: number | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
+ ): void;
+
+ /**
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ */
+ export function write(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
+
+ /**
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param string A string to write.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ * @param encoding The expected string encoding.
+ */
+ export function write(
+ fd: number,
+ string: string,
+ position: number | undefined | null,
+ encoding: BufferEncoding | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
+ ): void;
+
+ /**
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param string A string to write.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ */
+ export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
+
+ /**
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param string A string to write.
+ */
+ export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace write {
+ /**
+ * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ */
+ function __promisify__(
+ fd: number,
+ buffer?: TBuffer,
+ offset?: number,
+ length?: number,
+ position?: number | null,
+ ): Promise<{ bytesWritten: number, buffer: TBuffer }>;
+
+ /**
+ * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param string A string to write.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ * @param encoding The expected string encoding.
+ */
+ function __promisify__(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): Promise<{ bytesWritten: number, buffer: string }>;
+ }
+
+ /**
+ * Synchronously writes `buffer` to the file referenced by the supplied file descriptor, returning the number of bytes written.
+ * @param fd A file descriptor.
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ */
+ export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
+
+ /**
+ * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
+ * @param fd A file descriptor.
+ * @param string A string to write.
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
+ * @param encoding The expected string encoding.
+ */
+ export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
+
+ /**
+ * Asynchronously reads data from the file referenced by the supplied file descriptor.
+ * @param fd A file descriptor.
+ * @param buffer The buffer that the data will be written to.
+ * @param offset The offset in the buffer at which to start writing.
+ * @param length The number of bytes to read.
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
+ */
+ export function read(
+ fd: number,
+ buffer: TBuffer,
+ offset: number,
+ length: number,
+ position: number | null,
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
+ ): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace read {
+ /**
+ * @param fd A file descriptor.
+ * @param buffer The buffer that the data will be written to.
+ * @param offset The offset in the buffer at which to start writing.
+ * @param length The number of bytes to read.
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
+ */
+ function __promisify__(
+ fd: number,
+ buffer: TBuffer,
+ offset: number,
+ length: number,
+ position: number | null
+ ): Promise<{ bytesRead: number, buffer: TBuffer }>;
+ }
+
+ export interface ReadSyncOptions {
+ /**
+ * @default 0
+ */
+ offset?: number;
+ /**
+ * @default `length of buffer`
+ */
+ length?: number;
+ /**
+ * @default null
+ */
+ position?: number | null;
+ }
+
+ /**
+ * Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
+ * @param fd A file descriptor.
+ * @param buffer The buffer that the data will be written to.
+ * @param offset The offset in the buffer at which to start writing.
+ * @param length The number of bytes to read.
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
+ */
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
+
+ /**
+ * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
+ * If no `options` object is specified, it will default with the above values.
+ */
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options An object that may contain an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFile(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFile(
+ path: PathLike | number,
+ options: BaseEncodingOptions & { flag?: string; } | string | undefined | null,
+ callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
+ ): void;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ */
+ export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace readFile {
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options An object that may contain an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ function __promisify__(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Promise;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ function __promisify__(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string): Promise;
+
+ /**
+ * Asynchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ function __promisify__(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | string | null): Promise;
+ }
+
+ /**
+ * Synchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
+
+ /**
+ * Synchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFileSync(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | BufferEncoding): string;
+
+ /**
+ * Synchronously reads the entire contents of a file.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
+ * If a flag is not provided, it defaults to `'r'`.
+ */
+ export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | BufferEncoding | null): string | Buffer;
+
+ export type WriteFileOptions = BaseEncodingOptions & { mode?: Mode; flag?: string; } | string | null;
+
+ /**
+ * Asynchronously writes data to a file, replacing the file if it already exists.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'w'` is used.
+ */
+ export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronously writes data to a file, replacing the file if it already exists.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ */
+ export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace writeFile {
+ /**
+ * Asynchronously writes data to a file, replacing the file if it already exists.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'w'` is used.
+ */
+ function __promisify__(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise;
+ }
+
+ /**
+ * Synchronously writes data to a file, replacing the file if it already exists.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'w'` is used.
+ */
+ export function writeFileSync(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
+
+ /**
+ * Asynchronously append data to a file, creating the file if it does not exist.
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'a'` is used.
+ */
+ export function appendFile(file: PathLike | number, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronously append data to a file, creating the file if it does not exist.
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ */
+ export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace appendFile {
+ /**
+ * Asynchronously append data to a file, creating the file if it does not exist.
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'a'` is used.
+ */
+ function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise;
+ }
+
+ /**
+ * Synchronously append data to a file, creating the file if it does not exist.
+ * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
+ * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `mode` is not supplied, the default of `0o666` is used.
+ * If `mode` is a string, it is parsed as an octal integer.
+ * If `flag` is not supplied, the default of `'a'` is used.
+ */
+ export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void;
+
+ /**
+ * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
+ */
+ export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
+
+ /**
+ * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
+
+ /**
+ * Stop watching for changes on `filename`.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
+
+ /**
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `persistent` is not supplied, the default of `true` is used.
+ * If `recursive` is not supplied, the default of `false` is used.
+ */
+ export function watch(
+ filename: PathLike,
+ options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null,
+ listener?: (event: string, filename: string) => void,
+ ): FSWatcher;
+
+ /**
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `persistent` is not supplied, the default of `true` is used.
+ * If `recursive` is not supplied, the default of `false` is used.
+ */
+ export function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
+
+ /**
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
+ * If `persistent` is not supplied, the default of `true` is used.
+ * If `recursive` is not supplied, the default of `false` is used.
+ */
+ export function watch(
+ filename: PathLike,
+ options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | string | null,
+ listener?: (event: string, filename: string | Buffer) => void,
+ ): FSWatcher;
+
+ /**
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
+
+ /**
+ * Asynchronously tests whether or not the given path exists by checking with the file system.
+ * @deprecated since v1.0.0 Use `fs.stat()` or `fs.access()` instead
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function exists(path: PathLike, callback: (exists: boolean) => void): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace exists {
+ /**
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ function __promisify__(path: PathLike): Promise;
+ }
+
+ /**
+ * Synchronously tests whether or not the given path exists by checking with the file system.
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function existsSync(path: PathLike): boolean;
+
+ export namespace constants {
+ // File Access Constants
+
+ /** Constant for fs.access(). File is visible to the calling process. */
+ const F_OK: number;
+
+ /** Constant for fs.access(). File can be read by the calling process. */
+ const R_OK: number;
+
+ /** Constant for fs.access(). File can be written by the calling process. */
+ const W_OK: number;
+
+ /** Constant for fs.access(). File can be executed by the calling process. */
+ const X_OK: number;
+
+ // File Copy Constants
+
+ /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
+ const COPYFILE_EXCL: number;
+
+ /**
+ * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
+ * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
+ */
+ const COPYFILE_FICLONE: number;
+
+ /**
+ * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
+ * If the underlying platform does not support copy-on-write, then the operation will fail with an error.
+ */
+ const COPYFILE_FICLONE_FORCE: number;
+
+ // File Open Constants
+
+ /** Constant for fs.open(). Flag indicating to open a file for read-only access. */
+ const O_RDONLY: number;
+
+ /** Constant for fs.open(). Flag indicating to open a file for write-only access. */
+ const O_WRONLY: number;
+
+ /** Constant for fs.open(). Flag indicating to open a file for read-write access. */
+ const O_RDWR: number;
+
+ /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
+ const O_CREAT: number;
+
+ /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
+ const O_EXCL: number;
+
+ /**
+ * Constant for fs.open(). Flag indicating that if path identifies a terminal device,
+ * opening the path shall not cause that terminal to become the controlling terminal for the process
+ * (if the process does not already have one).
+ */
+ const O_NOCTTY: number;
+
+ /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
+ const O_TRUNC: number;
+
+ /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
+ const O_APPEND: number;
+
+ /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
+ const O_DIRECTORY: number;
+
+ /**
+ * constant for fs.open().
+ * Flag indicating reading accesses to the file system will no longer result in
+ * an update to the atime information associated with the file.
+ * This flag is available on Linux operating systems only.
+ */
+ const O_NOATIME: number;
+
+ /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
+ const O_NOFOLLOW: number;
+
+ /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
+ const O_SYNC: number;
+
+ /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
+ const O_DSYNC: number;
+
+ /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
+ const O_SYMLINK: number;
+
+ /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
+ const O_DIRECT: number;
+
+ /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
+ const O_NONBLOCK: number;
+
+ // File Type Constants
+
+ /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
+ const S_IFMT: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
+ const S_IFREG: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
+ const S_IFDIR: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
+ const S_IFCHR: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
+ const S_IFBLK: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
+ const S_IFIFO: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
+ const S_IFLNK: number;
+
+ /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
+ const S_IFSOCK: number;
+
+ // File Mode Constants
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
+ const S_IRWXU: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
+ const S_IRUSR: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
+ const S_IWUSR: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
+ const S_IXUSR: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
+ const S_IRWXG: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
+ const S_IRGRP: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
+ const S_IWGRP: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
+ const S_IXGRP: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
+ const S_IRWXO: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
+ const S_IROTH: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
+ const S_IWOTH: number;
+
+ /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
+ const S_IXOTH: number;
+
+ /**
+ * When set, a memory file mapping is used to access the file. This flag
+ * is available on Windows operating systems only. On other operating systems,
+ * this flag is ignored.
+ */
+ const UV_FS_O_FILEMAP: number;
+ }
+
+ /**
+ * Asynchronously tests a user's permissions for the file specified by path.
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
+
+ /**
+ * Asynchronously tests a user's permissions for the file specified by path.
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function access(path: PathLike, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace access {
+ /**
+ * Asynchronously tests a user's permissions for the file specified by path.
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ function __promisify__(path: PathLike, mode?: number): Promise;
+ }
+
+ /**
+ * Synchronously tests a user's permissions for the file specified by path.
+ * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function accessSync(path: PathLike, mode?: number): void;
+
+ /**
+ * Returns a new `ReadStream` object.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function createReadStream(path: PathLike, options?: string | {
+ flags?: string;
+ encoding?: BufferEncoding;
+ fd?: number;
+ mode?: number;
+ autoClose?: boolean;
+ /**
+ * @default false
+ */
+ emitClose?: boolean;
+ start?: number;
+ end?: number;
+ highWaterMark?: number;
+ }): ReadStream;
+
+ /**
+ * Returns a new `WriteStream` object.
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
+ * URL support is _experimental_.
+ */
+ export function createWriteStream(path: PathLike, options?: string | {
+ flags?: string;
+ encoding?: BufferEncoding;
+ fd?: number;
+ mode?: number;
+ autoClose?: boolean;
+ emitClose?: boolean;
+ start?: number;
+ highWaterMark?: number;
+ }): WriteStream;
+
+ /**
+ * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
+ * @param fd A file descriptor.
+ */
+ export function fdatasync(fd: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace fdatasync {
+ /**
+ * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
+ * @param fd A file descriptor.
+ */
+ function __promisify__(fd: number): Promise;
+ }
+
+ /**
+ * Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
+ * @param fd A file descriptor.
+ */
+ export function fdatasyncSync(fd: number): void;
+
+ /**
+ * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
+ * No arguments other than a possible exception are given to the callback function.
+ * Node.js makes no guarantees about the atomicity of the copy operation.
+ * If an error occurs after the destination file has been opened for writing, Node.js will attempt
+ * to remove the destination.
+ * @param src A path to the source file.
+ * @param dest A path to the destination file.
+ */
+ export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
+ /**
+ * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
+ * No arguments other than a possible exception are given to the callback function.
+ * Node.js makes no guarantees about the atomicity of the copy operation.
+ * If an error occurs after the destination file has been opened for writing, Node.js will attempt
+ * to remove the destination.
+ * @param src A path to the source file.
+ * @param dest A path to the destination file.
+ * @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
+ */
+ export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
+
+ // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
+ export namespace copyFile {
+ /**
+ * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
+ * No arguments other than a possible exception are given to the callback function.
+ * Node.js makes no guarantees about the atomicity of the copy operation.
+ * If an error occurs after the destination file has been opened for writing, Node.js will attempt
+ * to remove the destination.
+ * @param src A path to the source file.
+ * @param dest A path to the destination file.
+ * @param flags An optional integer that specifies the behavior of the copy operation.
+ * The only supported flag is fs.constants.COPYFILE_EXCL,
+ * which causes the copy operation to fail if dest already exists.
+ */
+ function __promisify__(src: PathLike, dst: PathLike, flags?: number): Promise;
+ }
+
+ /**
+ * Synchronously copies src to dest. By default, dest is overwritten if it already exists.
+ * Node.js makes no guarantees about the atomicity of the copy operation.
+ * If an error occurs after the destination file has been opened for writing, Node.js will attempt
+ * to remove the destination.
+ * @param src A path to the source file.
+ * @param dest A path to the destination file.
+ * @param flags An optional integer that specifies the behavior of the copy operation.
+ * The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
+ */
+ export function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
+
+ /**
+ * Write an array of ArrayBufferViews to the file specified by fd using writev().
+ * position is the offset from the beginning of the file where this data should be written.
+ * It is unsafe to use fs.writev() multiple times on the same file without waiting for the callback. For this scenario, use fs.createWriteStream().
+ * On Linux, positional writes don't work when the file is opened in append mode.
+ * The kernel ignores the position argument and always appends the data to the end of the file.
+ */
+ export function writev(
+ fd: number,
+ buffers: NodeJS.ArrayBufferView[],
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
+ ): void;
+ export function writev(
+ fd: number,
+ buffers: NodeJS.ArrayBufferView[],
+ position: number,
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
+ ): void;
+
+ export interface WriteVResult {
+ bytesWritten: number;
+ buffers: NodeJS.ArrayBufferView[];
+ }
+
+ export namespace writev {
+ function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise;
+ }
+
+ /**
+ * See `writev`.
+ */
+ export function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
+
+ export function readv(
+ fd: number,
+ buffers: NodeJS.ArrayBufferView[],
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
+ ): void;
+ export function readv(
+ fd: number,
+ buffers: NodeJS.ArrayBufferView[],
+ position: number,
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
+ ): void;
+
+ export interface ReadVResult {
+ bytesRead: number;
+ buffers: NodeJS.ArrayBufferView[];
+ }
+
+ export namespace readv {
+ function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise;
+ }
+
+ /**
+ * See `readv`.
+ */
+ export function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
+
+ export interface OpenDirOptions {
+ encoding?: BufferEncoding;
+ /**
+ * Number of directory entries that are buffered
+ * internally when reading from the directory. Higher values lead to better
+ * performance but higher memory usage.
+ * @default 32
+ */
+ bufferSize?: number;
+ }
+
+ export function opendirSync(path: string, options?: OpenDirOptions): Dir;
+
+ export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
+ export function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
+
+ export namespace opendir {
+ function __promisify__(path: string, options?: OpenDirOptions): Promise;
+ }
+
+ export interface BigIntStats extends StatsBase {
+ }
+
+ export class BigIntStats {
atimeNs: bigint;
mtimeNs: bigint;
ctimeNs: bigint;
birthtimeNs: bigint;
}
- interface BigIntOptions {
+ export interface BigIntOptions {
bigint: true;
}
- interface StatOptions {
+ export interface StatOptions {
bigint: boolean;
}
-
- function stat(path: PathLike, options: BigIntOptions, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
- function stat(path: PathLike, options: StatOptions, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
-
- namespace stat {
- function __promisify__(path: PathLike, options: BigIntOptions): Promise;
- function __promisify__(path: PathLike, options: StatOptions): Promise;
- }
-
- function statSync(path: PathLike, options: BigIntOptions): BigIntStats;
- function statSync(path: PathLike, options: StatOptions): Stats | BigIntStats;
}
diff --git a/types/node/globals.d.ts b/types/node/globals.d.ts
index a8c3e2a94f..76247f9a75 100644
--- a/types/node/globals.d.ts
+++ b/types/node/globals.d.ts
@@ -1,13 +1,606 @@
-// tslint:disable-next-line:no-bad-reference
-///
+// Declare "static" methods in Error
+interface ErrorConstructor {
+ /** Create .stack property on a target object */
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
-interface Buffer extends Uint8Array {
- readBigUInt64BE(offset?: number): bigint;
- readBigUInt64LE(offset?: number): bigint;
- readBigInt64BE(offset?: number): bigint;
- readBigInt64LE(offset?: number): bigint;
+ /**
+ * Optional override for formatting stack traces
+ *
+ * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces
+ */
+ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
+
+ stackTraceLimit: number;
+}
+
+// Node.js ESNEXT support
+interface String {
+ /** Removes whitespace from the left end of a string. */
+ trimLeft(): string;
+ /** Removes whitespace from the right end of a string. */
+ trimRight(): string;
+
+ /** Returns a copy with leading whitespace removed. */
+ trimStart(): string;
+ /** Returns a copy with trailing whitespace removed. */
+ trimEnd(): string;
+}
+
+interface ImportMeta {
+ url: string;
+}
+
+/*-----------------------------------------------*
+ * *
+ * GLOBAL *
+ * *
+ ------------------------------------------------*/
+
+// For backwards compability
+interface NodeRequire extends NodeJS.Require {}
+interface RequireResolve extends NodeJS.RequireResolve {}
+interface NodeModule extends NodeJS.Module {}
+
+declare var process: NodeJS.Process;
+declare var console: Console;
+
+declare var __filename: string;
+declare var __dirname: string;
+
+declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
+declare namespace setTimeout {
+ function __promisify__(ms: number): Promise;
+ function __promisify__(ms: number, value: T): Promise;
+}
+declare function clearTimeout(timeoutId: NodeJS.Timeout): void;
+declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
+declare function clearInterval(intervalId: NodeJS.Timeout): void;
+declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
+declare namespace setImmediate {
+ function __promisify__(): Promise;
+ function __promisify__(value: T): Promise;
+}
+declare function clearImmediate(immediateId: NodeJS.Immediate): void;
+
+declare function queueMicrotask(callback: () => void): void;
+
+declare var require: NodeRequire;
+declare var module: NodeModule;
+
+// Same as module.exports
+declare var exports: any;
+
+// Buffer class
+type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
+
+/**
+ * Raw data is stored in instances of the Buffer class.
+ * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
+ * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
+ */
+declare class Buffer extends Uint8Array {
+ /**
+ * Allocates a new buffer containing the given {str}.
+ *
+ * @param str String to store in buffer.
+ * @param encoding encoding to use, optional. Default is 'utf8'
+ * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
+ */
+ constructor(str: string, encoding?: BufferEncoding);
+ /**
+ * Allocates a new buffer of {size} octets.
+ *
+ * @param size count of octets to allocate.
+ * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
+ */
+ constructor(size: number);
+ /**
+ * Allocates a new buffer containing the given {array} of octets.
+ *
+ * @param array The octets to store.
+ * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
+ */
+ constructor(array: Uint8Array);
+ /**
+ * Produces a Buffer backed by the same allocated memory as
+ * the given {ArrayBuffer}/{SharedArrayBuffer}.
+ *
+ *
+ * @param arrayBuffer The ArrayBuffer with which to share memory.
+ * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
+ */
+ constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
+ /**
+ * Allocates a new buffer containing the given {array} of octets.
+ *
+ * @param array The octets to store.
+ * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
+ */
+ constructor(array: any[]);
+ /**
+ * Copies the passed {buffer} data onto a new {Buffer} instance.
+ *
+ * @param buffer The buffer to copy.
+ * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
+ */
+ constructor(buffer: Buffer);
+ /**
+ * When passed a reference to the .buffer property of a TypedArray instance,
+ * the newly created Buffer will share the same allocated memory as the TypedArray.
+ * The optional {byteOffset} and {length} arguments specify a memory range
+ * within the {arrayBuffer} that will be shared by the Buffer.
+ *
+ * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
+ */
+ static from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
+ /**
+ * Creates a new Buffer using the passed {data}
+ * @param data data to create a new Buffer
+ */
+ static from(data: number[]): Buffer;
+ static from(data: Uint8Array): Buffer;
+ /**
+ * Creates a new buffer containing the coerced value of an object
+ * A `TypeError` will be thrown if {obj} has not mentioned methods or is not of other type appropriate for `Buffer.from()` variants.
+ * @param obj An object supporting `Symbol.toPrimitive` or `valueOf()`.
+ */
+ static from(obj: { valueOf(): string | object } | { [Symbol.toPrimitive](hint: 'string'): string }, byteOffset?: number, length?: number): Buffer;
+ /**
+ * Creates a new Buffer containing the given JavaScript string {str}.
+ * If provided, the {encoding} parameter identifies the character encoding.
+ * If not provided, {encoding} defaults to 'utf8'.
+ */
+ static from(str: string, encoding?: BufferEncoding): Buffer;
+ /**
+ * Creates a new Buffer using the passed {data}
+ * @param values to create a new Buffer
+ */
+ static of(...items: number[]): Buffer;
+ /**
+ * Returns true if {obj} is a Buffer
+ *
+ * @param obj object to test.
+ */
+ static isBuffer(obj: any): obj is Buffer;
+ /**
+ * Returns true if {encoding} is a valid encoding argument.
+ * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
+ *
+ * @param encoding string to test.
+ */
+ static isEncoding(encoding: string): encoding is BufferEncoding;
+ /**
+ * Gives the actual byte length of a string. encoding defaults to 'utf8'.
+ * This is not the same as String.prototype.length since that returns the number of characters in a string.
+ *
+ * @param string string to test.
+ * @param encoding encoding used to evaluate (defaults to 'utf8')
+ */
+ static byteLength(
+ string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
+ encoding?: BufferEncoding
+ ): number;
+ /**
+ * Returns a buffer which is the result of concatenating all the buffers in the list together.
+ *
+ * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
+ * If the list has exactly one item, then the first item of the list is returned.
+ * If the list has more than one item, then a new Buffer is created.
+ *
+ * @param list An array of Buffer objects to concatenate
+ * @param totalLength Total length of the buffers when concatenated.
+ * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
+ */
+ static concat(list: Uint8Array[], totalLength?: number): Buffer;
+ /**
+ * The same as buf1.compare(buf2).
+ */
+ static compare(buf1: Uint8Array, buf2: Uint8Array): number;
+ /**
+ * Allocates a new buffer of {size} octets.
+ *
+ * @param size count of octets to allocate.
+ * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
+ * If parameter is omitted, buffer will be filled with zeros.
+ * @param encoding encoding used for call to buf.fill while initalizing
+ */
+ static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
+ /**
+ * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
+ * of the newly created Buffer are unknown and may contain sensitive data.
+ *
+ * @param size count of octets to allocate
+ */
+ static allocUnsafe(size: number): Buffer;
+ /**
+ * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
+ * of the newly created Buffer are unknown and may contain sensitive data.
+ *
+ * @param size count of octets to allocate
+ */
+ static allocUnsafeSlow(size: number): Buffer;
+ /**
+ * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
+ */
+ static poolSize: number;
+
+ write(string: string, encoding?: BufferEncoding): number;
+ write(string: string, offset: number, encoding?: BufferEncoding): number;
+ write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
+ toString(encoding?: BufferEncoding, start?: number, end?: number): string;
+ toJSON(): { type: 'Buffer'; data: number[] };
+ equals(otherBuffer: Uint8Array): boolean;
+ compare(
+ otherBuffer: Uint8Array,
+ targetStart?: number,
+ targetEnd?: number,
+ sourceStart?: number,
+ sourceEnd?: number
+ ): number;
+ copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
+ /**
+ * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
+ *
+ * This method is incompatible with `Uint8Array#slice()`, which returns a copy of the original memory.
+ *
+ * @param begin Where the new `Buffer` will start. Default: `0`.
+ * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
+ */
+ slice(begin?: number, end?: number): Buffer;
+ /**
+ * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
+ *
+ * This method is compatible with `Uint8Array#subarray()`.
+ *
+ * @param begin Where the new `Buffer` will start. Default: `0`.
+ * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
+ */
+ subarray(begin?: number, end?: number): Buffer;
writeBigInt64BE(value: bigint, offset?: number): number;
writeBigInt64LE(value: bigint, offset?: number): number;
writeBigUInt64BE(value: bigint, offset?: number): number;
writeBigUInt64LE(value: bigint, offset?: number): number;
+ writeUIntLE(value: number, offset: number, byteLength: number): number;
+ writeUIntBE(value: number, offset: number, byteLength: number): number;
+ writeIntLE(value: number, offset: number, byteLength: number): number;
+ writeIntBE(value: number, offset: number, byteLength: number): number;
+ readBigUInt64BE(offset?: number): bigint;
+ readBigUInt64LE(offset?: number): bigint;
+ readBigInt64BE(offset?: number): bigint;
+ readBigInt64LE(offset?: number): bigint;
+ readUIntLE(offset: number, byteLength: number): number;
+ readUIntBE(offset: number, byteLength: number): number;
+ readIntLE(offset: number, byteLength: number): number;
+ readIntBE(offset: number, byteLength: number): number;
+ readUInt8(offset?: number): number;
+ readUInt16LE(offset?: number): number;
+ readUInt16BE(offset?: number): number;
+ readUInt32LE(offset?: number): number;
+ readUInt32BE(offset?: number): number;
+ readInt8(offset?: number): number;
+ readInt16LE(offset?: number): number;
+ readInt16BE(offset?: number): number;
+ readInt32LE(offset?: number): number;
+ readInt32BE(offset?: number): number;
+ readFloatLE(offset?: number): number;
+ readFloatBE(offset?: number): number;
+ readDoubleLE(offset?: number): number;
+ readDoubleBE(offset?: number): number;
+ reverse(): this;
+ swap16(): Buffer;
+ swap32(): Buffer;
+ swap64(): Buffer;
+ writeUInt8(value: number, offset?: number): number;
+ writeUInt16LE(value: number, offset?: number): number;
+ writeUInt16BE(value: number, offset?: number): number;
+ writeUInt32LE(value: number, offset?: number): number;
+ writeUInt32BE(value: number, offset?: number): number;
+ writeInt8(value: number, offset?: number): number;
+ writeInt16LE(value: number, offset?: number): number;
+ writeInt16BE(value: number, offset?: number): number;
+ writeInt32LE(value: number, offset?: number): number;
+ writeInt32BE(value: number, offset?: number): number;
+ writeFloatLE(value: number, offset?: number): number;
+ writeFloatBE(value: number, offset?: number): number;
+ writeDoubleLE(value: number, offset?: number): number;
+ writeDoubleBE(value: number, offset?: number): number;
+
+ fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
+
+ indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
+ lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
+ entries(): IterableIterator<[number, number]>;
+ includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
+ keys(): IterableIterator;
+ values(): IterableIterator;
+}
+
+/*----------------------------------------------*
+* *
+* GLOBAL INTERFACES *
+* *
+*-----------------------------------------------*/
+declare namespace NodeJS {
+ interface InspectOptions {
+ /**
+ * If set to `true`, getters are going to be
+ * inspected as well. If set to `'get'` only getters without setter are going
+ * to be inspected. If set to `'set'` only getters having a corresponding
+ * setter are going to be inspected. This might cause side effects depending on
+ * the getter function.
+ * @default `false`
+ */
+ getters?: 'get' | 'set' | boolean;
+ showHidden?: boolean;
+ /**
+ * @default 2
+ */
+ depth?: number | null;
+ colors?: boolean;
+ customInspect?: boolean;
+ showProxy?: boolean;
+ maxArrayLength?: number | null;
+ /**
+ * Specifies the maximum number of characters to
+ * include when formatting. Set to `null` or `Infinity` to show all elements.
+ * Set to `0` or negative to show no characters.
+ * @default Infinity
+ */
+ maxStringLength?: number | null;
+ breakLength?: number;
+ /**
+ * Setting this to `false` causes each object key
+ * to be displayed on a new line. It will also add new lines to text that is
+ * longer than `breakLength`. If set to a number, the most `n` inner elements
+ * are united on a single line as long as all properties fit into
+ * `breakLength`. Short array elements are also grouped together. Note that no
+ * text will be reduced below 16 characters, no matter the `breakLength` size.
+ * For more information, see the example below.
+ * @default `true`
+ */
+ compact?: boolean | number;
+ sorted?: boolean | ((a: string, b: string) => number);
+ }
+
+ interface CallSite {
+ /**
+ * Value of "this"
+ */
+ getThis(): any;
+
+ /**
+ * Type of "this" as a string.
+ * This is the name of the function stored in the constructor field of
+ * "this", if available. Otherwise the object's [[Class]] internal
+ * property.
+ */
+ getTypeName(): string | null;
+
+ /**
+ * Current function
+ */
+ getFunction(): Function | undefined;
+
+ /**
+ * Name of the current function, typically its name property.
+ * If a name property is not available an attempt will be made to try
+ * to infer a name from the function's context.
+ */
+ getFunctionName(): string | null;
+
+ /**
+ * Name of the property [of "this" or one of its prototypes] that holds
+ * the current function
+ */
+ getMethodName(): string | null;
+
+ /**
+ * Name of the script [if this function was defined in a script]
+ */
+ getFileName(): string | null;
+
+ /**
+ * Current line number [if this function was defined in a script]
+ */
+ getLineNumber(): number | null;
+
+ /**
+ * Current column number [if this function was defined in a script]
+ */
+ getColumnNumber(): number | null;
+
+ /**
+ * A call site object representing the location where eval was called
+ * [if this function was created using a call to eval]
+ */
+ getEvalOrigin(): string | undefined;
+
+ /**
+ * Is this a toplevel invocation, that is, is "this" the global object?
+ */
+ isToplevel(): boolean;
+
+ /**
+ * Does this call take place in code defined by a call to eval?
+ */
+ isEval(): boolean;
+
+ /**
+ * Is this call in native V8 code?
+ */
+ isNative(): boolean;
+
+ /**
+ * Is this a constructor call?
+ */
+ isConstructor(): boolean;
+ }
+
+ interface ErrnoException extends Error {
+ errno?: number;
+ code?: string;
+ path?: string;
+ syscall?: string;
+ stack?: string;
+ }
+
+ interface ReadableStream extends EventEmitter {
+ readable: boolean;
+ read(size?: number): string | Buffer;
+ setEncoding(encoding: BufferEncoding): this;
+ pause(): this;
+ resume(): this;
+ isPaused(): boolean;
+ pipe(destination: T, options?: { end?: boolean; }): T;
+ unpipe(destination?: WritableStream): this;
+ unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
+ wrap(oldStream: ReadableStream): this;
+ [Symbol.asyncIterator](): AsyncIterableIterator;
+ }
+
+ interface WritableStream extends EventEmitter {
+ writable: boolean;
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
+ write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
+ end(cb?: () => void): void;
+ end(data: string | Uint8Array, cb?: () => void): void;
+ end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
+ }
+
+ interface ReadWriteStream extends ReadableStream, WritableStream { }
+
+ interface Global {
+ Array: typeof Array;
+ ArrayBuffer: typeof ArrayBuffer;
+ Boolean: typeof Boolean;
+ Buffer: typeof Buffer;
+ DataView: typeof DataView;
+ Date: typeof Date;
+ Error: typeof Error;
+ EvalError: typeof EvalError;
+ Float32Array: typeof Float32Array;
+ Float64Array: typeof Float64Array;
+ Function: typeof Function;
+ Infinity: typeof Infinity;
+ Int16Array: typeof Int16Array;
+ Int32Array: typeof Int32Array;
+ Int8Array: typeof Int8Array;
+ Intl: typeof Intl;
+ JSON: typeof JSON;
+ Map: MapConstructor;
+ Math: typeof Math;
+ NaN: typeof NaN;
+ Number: typeof Number;
+ Object: typeof Object;
+ Promise: typeof Promise;
+ RangeError: typeof RangeError;
+ ReferenceError: typeof ReferenceError;
+ RegExp: typeof RegExp;
+ Set: SetConstructor;
+ String: typeof String;
+ Symbol: Function;
+ SyntaxError: typeof SyntaxError;
+ TypeError: typeof TypeError;
+ URIError: typeof URIError;
+ Uint16Array: typeof Uint16Array;
+ Uint32Array: typeof Uint32Array;
+ Uint8Array: typeof Uint8Array;
+ Uint8ClampedArray: typeof Uint8ClampedArray;
+ WeakMap: WeakMapConstructor;
+ WeakSet: WeakSetConstructor;
+ clearImmediate: (immediateId: Immediate) => void;
+ clearInterval: (intervalId: Timeout) => void;
+ clearTimeout: (timeoutId: Timeout) => void;
+ decodeURI: typeof decodeURI;
+ decodeURIComponent: typeof decodeURIComponent;
+ encodeURI: typeof encodeURI;
+ encodeURIComponent: typeof encodeURIComponent;
+ escape: (str: string) => string;
+ eval: typeof eval;
+ global: Global;
+ isFinite: typeof isFinite;
+ isNaN: typeof isNaN;
+ parseFloat: typeof parseFloat;
+ parseInt: typeof parseInt;
+ setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
+ setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
+ setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
+ queueMicrotask: typeof queueMicrotask;
+ undefined: typeof undefined;
+ unescape: (str: string) => string;
+ gc: () => void;
+ v8debug?: any;
+ }
+
+ interface RefCounted {
+ ref(): this;
+ unref(): this;
+ }
+
+ // compatibility with older typings
+ interface Timer extends RefCounted {
+ hasRef(): boolean;
+ refresh(): this;
+ }
+
+ interface Immediate extends RefCounted {
+ hasRef(): boolean;
+ _onImmediate: Function; // to distinguish it from the Timeout class
+ }
+
+ interface Timeout extends Timer {
+ hasRef(): boolean;
+ refresh(): this;
+ }
+
+ type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
+ type ArrayBufferView = TypedArray | DataView;
+
+ interface Require {
+ /* tslint:disable-next-line:callable-types */
+ (id: string): any;
+ resolve: RequireResolve;
+ cache: Dict;
+ /**
+ * @deprecated
+ */
+ extensions: RequireExtensions;
+ main: Module | undefined;
+ }
+
+ interface RequireResolve {
+ (id: string, options?: { paths?: string[]; }): string;
+ paths(request: string): string[] | null;
+ }
+
+ interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
+ '.js': (m: Module, filename: string) => any;
+ '.json': (m: Module, filename: string) => any;
+ '.node': (m: Module, filename: string) => any;
+ }
+ interface Module {
+ exports: any;
+ require: Require;
+ id: string;
+ filename: string;
+ loaded: boolean;
+ /** @deprecated since 14.6.0 Please use `require.main` and `module.children` instead. */
+ parent: Module | null | undefined;
+ children: Module[];
+ /**
+ * @since 11.14.0
+ *
+ * The directory name of the module. This is usually the same as the path.dirname() of the module.id.
+ */
+ path: string;
+ paths: string[];
+ }
+
+ interface Dict {
+ [key: string]: T | undefined;
+ }
+
+ interface ReadOnlyDict {
+ readonly [key: string]: T | undefined;
+ }
}
diff --git a/types/node/package.json b/types/node/package.json
index dd84e4f705..b17d6c5bc5 100644
--- a/types/node/package.json
+++ b/types/node/package.json
@@ -2,11 +2,6 @@
"private": true,
"types": "index",
"typesVersions": {
- "<=3.1": {
- "*": [
- "ts3.1/*"
- ]
- },
"<=3.4": {
"*": [
"ts3.4/*"
diff --git a/types/node/process.d.ts b/types/node/process.d.ts
index 352a196401..07c918350c 100644
--- a/types/node/process.d.ts
+++ b/types/node/process.d.ts
@@ -1,12 +1,406 @@
-// tslint:disable-next-line:no-bad-reference
-///
+declare module "process" {
+ import * as tty from "tty";
-declare module 'process' {
global {
+ var process: NodeJS.Process;
+
namespace NodeJS {
+ // this namespace merge is here because these are specifically used
+ // as the type for process.stdin, process.stdout, and process.stderr.
+ // they can't live in tty.d.ts because we need to disambiguate the imported name.
+ interface ReadStream extends tty.ReadStream {}
+ interface WriteStream extends tty.WriteStream {}
+
+ interface MemoryUsage {
+ rss: number;
+ heapTotal: number;
+ heapUsed: number;
+ external: number;
+ arrayBuffers: number;
+ }
+
+ interface CpuUsage {
+ user: number;
+ system: number;
+ }
+
+ interface ProcessRelease {
+ name: string;
+ sourceUrl?: string;
+ headersUrl?: string;
+ libUrl?: string;
+ lts?: string;
+ }
+
+ interface ProcessVersions extends Dict {
+ http_parser: string;
+ node: string;
+ v8: string;
+ ares: string;
+ uv: string;
+ zlib: string;
+ modules: string;
+ openssl: string;
+ }
+
+ type Platform = 'aix'
+ | 'android'
+ | 'darwin'
+ | 'freebsd'
+ | 'linux'
+ | 'openbsd'
+ | 'sunos'
+ | 'win32'
+ | 'cygwin'
+ | 'netbsd';
+
+ type Signals =
+ "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
+ "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
+ "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
+ "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
+
+ type MultipleResolveType = 'resolve' | 'reject';
+
+ type BeforeExitListener = (code: number) => void;
+ type DisconnectListener = () => void;
+ type ExitListener = (code: number) => void;
+ type RejectionHandledListener = (promise: Promise) => void;
+ type UncaughtExceptionListener = (error: Error) => void;
+ type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise) => void;
+ type WarningListener = (warning: Error) => void;
+ type MessageListener = (message: any, sendHandle: any) => void;
+ type SignalsListener = (signal: Signals) => void;
+ type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
+ type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
+ type MultipleResolveListener = (type: MultipleResolveType, promise: Promise, value: any) => void;
+
+ interface Socket extends ReadWriteStream {
+ isTTY?: true;
+ }
+
+ // Alias for compatibility
+ interface ProcessEnv extends Dict {}
+
interface HRTime {
+ (time?: [number, number]): [number, number];
bigint(): bigint;
}
+
+ interface ProcessReport {
+ /**
+ * Directory where the report is written.
+ * working directory of the Node.js process.
+ * @default '' indicating that reports are written to the current
+ */
+ directory: string;
+
+ /**
+ * Filename where the report is written.
+ * The default value is the empty string.
+ * @default '' the output filename will be comprised of a timestamp,
+ * PID, and sequence number.
+ */
+ filename: string;
+
+ /**
+ * Returns a JSON-formatted diagnostic report for the running process.
+ * The report's JavaScript stack trace is taken from err, if present.
+ */
+ getReport(err?: Error): string;
+
+ /**
+ * If true, a diagnostic report is generated on fatal errors,
+ * such as out of memory errors or failed C++ assertions.
+ * @default false
+ */
+ reportOnFatalError: boolean;
+
+ /**
+ * If true, a diagnostic report is generated when the process
+ * receives the signal specified by process.report.signal.
+ * @defaul false
+ */
+ reportOnSignal: boolean;
+
+ /**
+ * If true, a diagnostic report is generated on uncaught exception.
+ * @default false
+ */
+ reportOnUncaughtException: boolean;
+
+ /**
+ * The signal used to trigger the creation of a diagnostic report.
+ * @default 'SIGUSR2'
+ */
+ signal: Signals;
+
+ /**
+ * Writes a diagnostic report to a file. If filename is not provided, the default filename
+ * includes the date, time, PID, and a sequence number.
+ * The report's JavaScript stack trace is taken from err, if present.
+ *
+ * @param fileName Name of the file where the report is written.
+ * This should be a relative path, that will be appended to the directory specified in
+ * `process.report.directory`, or the current working directory of the Node.js process,
+ * if unspecified.
+ * @param error A custom error used for reporting the JavaScript stack.
+ * @return Filename of the generated report.
+ */
+ writeReport(fileName?: string): string;
+ writeReport(error?: Error): string;
+ writeReport(fileName?: string, err?: Error): string;
+ }
+
+ interface ResourceUsage {
+ fsRead: number;
+ fsWrite: number;
+ involuntaryContextSwitches: number;
+ ipcReceived: number;
+ ipcSent: number;
+ majorPageFault: number;
+ maxRSS: number;
+ minorPageFault: number;
+ sharedMemorySize: number;
+ signalsCount: number;
+ swappedOut: number;
+ systemCPUTime: number;
+ unsharedDataSize: number;
+ unsharedStackSize: number;
+ userCPUTime: number;
+ voluntaryContextSwitches: number;
+ }
+
+ interface Process extends EventEmitter {
+ /**
+ * Can also be a tty.WriteStream, not typed due to limitations.
+ */
+ stdout: WriteStream & {
+ fd: 1;
+ };
+ /**
+ * Can also be a tty.WriteStream, not typed due to limitations.
+ */
+ stderr: WriteStream & {
+ fd: 2;
+ };
+ stdin: ReadStream & {
+ fd: 0;
+ };
+ openStdin(): Socket;
+ argv: string[];
+ argv0: string;
+ execArgv: string[];
+ execPath: string;
+ abort(): void;
+ chdir(directory: string): void;
+ cwd(): string;
+ debugPort: number;
+ emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
+ env: ProcessEnv;
+ exit(code?: number): never;
+ exitCode?: number;
+ getgid(): number;
+ setgid(id: number | string): void;
+ getuid(): number;
+ setuid(id: number | string): void;
+ geteuid(): number;
+ seteuid(id: number | string): void;
+ getegid(): number;
+ setegid(id: number | string): void;
+ getgroups(): number[];
+ setgroups(groups: Array): void;
+ setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
+ hasUncaughtExceptionCaptureCallback(): boolean;
+ version: string;
+ versions: ProcessVersions;
+ config: {
+ target_defaults: {
+ cflags: any[];
+ default_configuration: string;
+ defines: string[];
+ include_dirs: string[];
+ libraries: string[];
+ };
+ variables: {
+ clang: number;
+ host_arch: string;
+ node_install_npm: boolean;
+ node_install_waf: boolean;
+ node_prefix: string;
+ node_shared_openssl: boolean;
+ node_shared_v8: boolean;
+ node_shared_zlib: boolean;
+ node_use_dtrace: boolean;
+ node_use_etw: boolean;
+ node_use_openssl: boolean;
+ target_arch: string;
+ v8_no_strict_aliasing: number;
+ v8_use_snapshot: boolean;
+ visibility: string;
+ };
+ };
+ kill(pid: number, signal?: string | number): true;
+ pid: number;
+ ppid: number;
+ title: string;
+ arch: string;
+ platform: Platform;
+ /** @deprecated since v14.0.0 - use `require.main` instead. */
+ mainModule?: Module;
+ memoryUsage(): MemoryUsage;
+ cpuUsage(previousValue?: CpuUsage): CpuUsage;
+ nextTick(callback: Function, ...args: any[]): void;
+ release: ProcessRelease;
+ features: {
+ inspector: boolean;
+ debug: boolean;
+ uv: boolean;
+ ipv6: boolean;
+ tls_alpn: boolean;
+ tls_sni: boolean;
+ tls_ocsp: boolean;
+ tls: boolean;
+ };
+ /**
+ * @deprecated since v14.0.0 - Calling process.umask() with no argument causes
+ * the process-wide umask to be written twice. This introduces a race condition between threads,
+ * and is a potential security vulnerability. There is no safe, cross-platform alternative API.
+ */
+ umask(): number;
+ /**
+ * Can only be set if not in worker thread.
+ */
+ umask(mask: number): number;
+ uptime(): number;
+ hrtime: HRTime;
+ domain: Domain;
+
+ // Worker
+ send?(message: any, sendHandle?: any, options?: { swallowErrors?: boolean}, callback?: (error: Error | null) => void): boolean;
+ disconnect(): void;
+ connected: boolean;
+
+ /**
+ * The `process.allowedNodeEnvironmentFlags` property is a special,
+ * read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
+ * environment variable.
+ */
+ allowedNodeEnvironmentFlags: ReadonlySet;
+
+ /**
+ * Only available with `--experimental-report`
+ */
+ report?: ProcessReport;
+
+ resourceUsage(): ResourceUsage;
+
+ /* EventEmitter */
+ addListener(event: "beforeExit", listener: BeforeExitListener): this;
+ addListener(event: "disconnect", listener: DisconnectListener): this;
+ addListener(event: "exit", listener: ExitListener): this;
+ addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
+ addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
+ addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
+ addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
+ addListener(event: "warning", listener: WarningListener): this;
+ addListener(event: "message", listener: MessageListener): this;
+ addListener(event: Signals, listener: SignalsListener): this;
+ addListener(event: "newListener", listener: NewListenerListener): this;
+ addListener(event: "removeListener", listener: RemoveListenerListener): this;
+ addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
+
+ emit(event: "beforeExit", code: number): boolean;
+ emit(event: "disconnect"): boolean;
+ emit(event: "exit", code: number): boolean;
+ emit(event: "rejectionHandled", promise: Promise): boolean;
+ emit(event: "uncaughtException", error: Error): boolean;
+ emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
+ emit(event: "unhandledRejection", reason: any, promise: Promise): boolean;
+ emit(event: "warning", warning: Error): boolean;
+ emit(event: "message", message: any, sendHandle: any): this;
+ emit(event: Signals, signal: Signals): boolean;
+ emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
+ emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
+ emit(event: "multipleResolves", listener: MultipleResolveListener): this;
+
+ on(event: "beforeExit", listener: BeforeExitListener): this;
+ on(event: "disconnect", listener: DisconnectListener): this;
+ on(event: "exit", listener: ExitListener): this;
+ on(event: "rejectionHandled", listener: RejectionHandledListener): this;
+ on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
+ on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
+ on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
+ on(event: "warning", listener: WarningListener): this;
+ on(event: "message", listener: MessageListener): this;
+ on(event: Signals, listener: SignalsListener): this;
+ on(event: "newListener", listener: NewListenerListener): this;
+ on(event: "removeListener", listener: RemoveListenerListener): this;
+ on(event: "multipleResolves", listener: MultipleResolveListener): this;
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
+
+ once(event: "beforeExit", listener: BeforeExitListener): this;
+ once(event: "disconnect", listener: DisconnectListener): this;
+ once(event: "exit", listener: ExitListener): this;
+ once(event: "rejectionHandled", listener: RejectionHandledListener): this;
+ once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
+ once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
+ once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
+ once(event: "warning", listener: WarningListener): this;
+ once(event: "message", listener: MessageListener): this;
+ once(event: Signals, listener: SignalsListener): this;
+ once(event: "newListener", listener: NewListenerListener): this;
+ once(event: "removeListener", listener: RemoveListenerListener): this;
+ once(event: "multipleResolves", listener: MultipleResolveListener): this;
+
+ prependListener(event: "beforeExit", listener: BeforeExitListener): this;
+ prependListener(event: "disconnect", listener: DisconnectListener): this;
+ prependListener(event: "exit", listener: ExitListener): this;
+ prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
+ prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
+ prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
+ prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
+ prependListener(event: "warning", listener: WarningListener): this;
+ prependListener(event: "message", listener: MessageListener): this;
+ prependListener(event: Signals, listener: SignalsListener): this;
+ prependListener(event: "newListener", listener: NewListenerListener): this;
+ prependListener(event: "removeListener", listener: RemoveListenerListener): this;
+ prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
+
+ prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
+ prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
+ prependOnceListener(event: "exit", listener: ExitListener): this;
+ prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
+ prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
+ prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
+ prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
+ prependOnceListener(event: "warning", listener: WarningListener): this;
+ prependOnceListener(event: "message", listener: MessageListener): this;
+ prependOnceListener(event: Signals, listener: SignalsListener): this;
+ prependOnceListener(event: "newListener", listener: NewListenerListener): this;
+ prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
+ prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
+
+ listeners(event: "beforeExit"): BeforeExitListener[];
+ listeners(event: "disconnect"): DisconnectListener[];
+ listeners(event: "exit"): ExitListener[];
+ listeners(event: "rejectionHandled"): RejectionHandledListener[];
+ listeners(event: "uncaughtException"): UncaughtExceptionListener[];
+ listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
+ listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
+ listeners(event: "warning"): WarningListener[];
+ listeners(event: "message"): MessageListener[];
+ listeners(event: Signals): SignalsListener[];
+ listeners(event: "newListener"): NewListenerListener[];
+ listeners(event: "removeListener"): RemoveListenerListener[];
+ listeners(event: "multipleResolves"): MultipleResolveListener[];
+ }
+
+ interface Global {
+ process: Process;
+ }
}
}
+
+ export = process;
}
diff --git a/types/node/ts3.1/base.d.ts b/types/node/ts3.1/base.d.ts
deleted file mode 100644
index f0c6ff0ad2..0000000000
--- a/types/node/ts3.1/base.d.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-// base definitions for all NodeJS modules that are not specific to any version of TypeScript
-
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
diff --git a/types/node/ts3.1/fs.d.ts b/types/node/ts3.1/fs.d.ts
deleted file mode 100644
index d4849bf43b..0000000000
--- a/types/node/ts3.1/fs.d.ts
+++ /dev/null
@@ -1,2132 +0,0 @@
-declare module "fs" {
- import * as stream from "stream";
- import * as events from "events";
- import { URL } from "url";
- import * as promises from 'fs/promises';
-
- export { promises };
- /**
- * Valid types for path values in "fs".
- */
- export type PathLike = string | Buffer | URL;
-
- export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
-
- export type BufferEncodingOption = 'buffer' | { encoding: 'buffer' };
-
- export interface BaseEncodingOptions {
- encoding?: BufferEncoding | null;
- }
-
- export type OpenMode = number | string;
-
- export type Mode = number | string;
-
- export interface StatsBase {
- isFile(): boolean;
- isDirectory(): boolean;
- isBlockDevice(): boolean;
- isCharacterDevice(): boolean;
- isSymbolicLink(): boolean;
- isFIFO(): boolean;
- isSocket(): boolean;
-
- dev: T;
- ino: T;
- mode: T;
- nlink: T;
- uid: T;
- gid: T;
- rdev: T;
- size: T;
- blksize: T;
- blocks: T;
- atimeMs: T;
- mtimeMs: T;
- ctimeMs: T;
- birthtimeMs: T;
- atime: Date;
- mtime: Date;
- ctime: Date;
- birthtime: Date;
- }
-
- export interface Stats extends StatsBase {
- }
-
- export class Stats {
- }
-
- export class Dirent {
- isFile(): boolean;
- isDirectory(): boolean;
- isBlockDevice(): boolean;
- isCharacterDevice(): boolean;
- isSymbolicLink(): boolean;
- isFIFO(): boolean;
- isSocket(): boolean;
- name: string;
- }
-
- /**
- * A class representing a directory stream.
- */
- export class Dir {
- readonly path: string;
-
- /**
- * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
- */
- [Symbol.asyncIterator](): AsyncIterableIterator;
-
- /**
- * Asynchronously close the directory's underlying resource handle.
- * Subsequent reads will result in errors.
- */
- close(): Promise;
- close(cb: NoParamCallback): void;
-
- /**
- * Synchronously close the directory's underlying resource handle.
- * Subsequent reads will result in errors.
- */
- closeSync(): void;
-
- /**
- * Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
- * After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.
- * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
- */
- read(): Promise;
- read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
-
- /**
- * Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
- * If there are no more directory entries to read, null will be returned.
- * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
- */
- readSync(): Dirent;
- }
-
- export interface FSWatcher extends events.EventEmitter {
- close(): void;
-
- /**
- * events.EventEmitter
- * 1. change
- * 2. error
- */
- addListener(event: string, listener: (...args: any[]) => void): this;
- addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
- addListener(event: "error", listener: (error: Error) => void): this;
- addListener(event: "close", listener: () => void): this;
-
- on(event: string, listener: (...args: any[]) => void): this;
- on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
- on(event: "error", listener: (error: Error) => void): this;
- on(event: "close", listener: () => void): this;
-
- once(event: string, listener: (...args: any[]) => void): this;
- once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
- once(event: "error", listener: (error: Error) => void): this;
- once(event: "close", listener: () => void): this;
-
- prependListener(event: string, listener: (...args: any[]) => void): this;
- prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
- prependListener(event: "error", listener: (error: Error) => void): this;
- prependListener(event: "close", listener: () => void): this;
-
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
- prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
- prependOnceListener(event: "error", listener: (error: Error) => void): this;
- prependOnceListener(event: "close", listener: () => void): this;
- }
-
- export class ReadStream extends stream.Readable {
- close(): void;
- bytesRead: number;
- path: string | Buffer;
- pending: boolean;
-
- /**
- * events.EventEmitter
- * 1. open
- * 2. close
- * 3. ready
- */
- addListener(event: "close", listener: () => void): this;
- addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
- addListener(event: "end", listener: () => void): this;
- addListener(event: "error", listener: (err: Error) => void): this;
- addListener(event: "open", listener: (fd: number) => void): this;
- addListener(event: "pause", listener: () => void): this;
- addListener(event: "readable", listener: () => void): this;
- addListener(event: "ready", listener: () => void): this;
- addListener(event: "resume", listener: () => void): this;
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- on(event: "close", listener: () => void): this;
- on(event: "data", listener: (chunk: Buffer | string) => void): this;
- on(event: "end", listener: () => void): this;
- on(event: "error", listener: (err: Error) => void): this;
- on(event: "open", listener: (fd: number) => void): this;
- on(event: "pause", listener: () => void): this;
- on(event: "readable", listener: () => void): this;
- on(event: "ready", listener: () => void): this;
- on(event: "resume", listener: () => void): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
-
- once(event: "close", listener: () => void): this;
- once(event: "data", listener: (chunk: Buffer | string) => void): this;
- once(event: "end", listener: () => void): this;
- once(event: "error", listener: (err: Error) => void): this;
- once(event: "open", listener: (fd: number) => void): this;
- once(event: "pause", listener: () => void): this;
- once(event: "readable", listener: () => void): this;
- once(event: "ready", listener: () => void): this;
- once(event: "resume", listener: () => void): this;
- once(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependListener(event: "close", listener: () => void): this;
- prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
- prependListener(event: "end", listener: () => void): this;
- prependListener(event: "error", listener: (err: Error) => void): this;
- prependListener(event: "open", listener: (fd: number) => void): this;
- prependListener(event: "pause", listener: () => void): this;
- prependListener(event: "readable", listener: () => void): this;
- prependListener(event: "ready", listener: () => void): this;
- prependListener(event: "resume", listener: () => void): this;
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependOnceListener(event: "close", listener: () => void): this;
- prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
- prependOnceListener(event: "end", listener: () => void): this;
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
- prependOnceListener(event: "open", listener: (fd: number) => void): this;
- prependOnceListener(event: "pause", listener: () => void): this;
- prependOnceListener(event: "readable", listener: () => void): this;
- prependOnceListener(event: "ready", listener: () => void): this;
- prependOnceListener(event: "resume", listener: () => void): this;
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
- }
-
- export class WriteStream extends stream.Writable {
- close(): void;
- bytesWritten: number;
- path: string | Buffer;
- pending: boolean;
-
- /**
- * events.EventEmitter
- * 1. open
- * 2. close
- * 3. ready
- */
- addListener(event: "close", listener: () => void): this;
- addListener(event: "drain", listener: () => void): this;
- addListener(event: "error", listener: (err: Error) => void): this;
- addListener(event: "finish", listener: () => void): this;
- addListener(event: "open", listener: (fd: number) => void): this;
- addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
- addListener(event: "ready", listener: () => void): this;
- addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- on(event: "close", listener: () => void): this;
- on(event: "drain", listener: () => void): this;
- on(event: "error", listener: (err: Error) => void): this;
- on(event: "finish", listener: () => void): this;
- on(event: "open", listener: (fd: number) => void): this;
- on(event: "pipe", listener: (src: stream.Readable) => void): this;
- on(event: "ready", listener: () => void): this;
- on(event: "unpipe", listener: (src: stream.Readable) => void): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
-
- once(event: "close", listener: () => void): this;
- once(event: "drain", listener: () => void): this;
- once(event: "error", listener: (err: Error) => void): this;
- once(event: "finish", listener: () => void): this;
- once(event: "open", listener: (fd: number) => void): this;
- once(event: "pipe", listener: (src: stream.Readable) => void): this;
- once(event: "ready", listener: () => void): this;
- once(event: "unpipe", listener: (src: stream.Readable) => void): this;
- once(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependListener(event: "close", listener: () => void): this;
- prependListener(event: "drain", listener: () => void): this;
- prependListener(event: "error", listener: (err: Error) => void): this;
- prependListener(event: "finish", listener: () => void): this;
- prependListener(event: "open", listener: (fd: number) => void): this;
- prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
- prependListener(event: "ready", listener: () => void): this;
- prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
- prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
-
- prependOnceListener(event: "close", listener: () => void): this;
- prependOnceListener(event: "drain", listener: () => void): this;
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
- prependOnceListener(event: "finish", listener: () => void): this;
- prependOnceListener(event: "open", listener: (fd: number) => void): this;
- prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
- prependOnceListener(event: "ready", listener: () => void): this;
- prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
- prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
- }
-
- /**
- * Asynchronous rename(2) - Change the name or location of a file or directory.
- * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace rename {
- /**
- * Asynchronous rename(2) - Change the name or location of a file or directory.
- * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- function __promisify__(oldPath: PathLike, newPath: PathLike): Promise;
- }
-
- /**
- * Synchronous rename(2) - Change the name or location of a file or directory.
- * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function renameSync(oldPath: PathLike, newPath: PathLike): void;
-
- /**
- * Asynchronous truncate(2) - Truncate a file to a specified length.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param len If not specified, defaults to `0`.
- */
- export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
-
- /**
- * Asynchronous truncate(2) - Truncate a file to a specified length.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function truncate(path: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace truncate {
- /**
- * Asynchronous truncate(2) - Truncate a file to a specified length.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param len If not specified, defaults to `0`.
- */
- function __promisify__(path: PathLike, len?: number | null): Promise;
- }
-
- /**
- * Synchronous truncate(2) - Truncate a file to a specified length.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param len If not specified, defaults to `0`.
- */
- export function truncateSync(path: PathLike, len?: number | null): void;
-
- /**
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
- * @param fd A file descriptor.
- * @param len If not specified, defaults to `0`.
- */
- export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
-
- /**
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
- * @param fd A file descriptor.
- */
- export function ftruncate(fd: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace ftruncate {
- /**
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
- * @param fd A file descriptor.
- * @param len If not specified, defaults to `0`.
- */
- function __promisify__(fd: number, len?: number | null): Promise;
- }
-
- /**
- * Synchronous ftruncate(2) - Truncate a file to a specified length.
- * @param fd A file descriptor.
- * @param len If not specified, defaults to `0`.
- */
- export function ftruncateSync(fd: number, len?: number | null): void;
-
- /**
- * Asynchronous chown(2) - Change ownership of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace chown {
- /**
- * Asynchronous chown(2) - Change ownership of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike, uid: number, gid: number): Promise;
- }
-
- /**
- * Synchronous chown(2) - Change ownership of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function chownSync(path: PathLike, uid: number, gid: number): void;
-
- /**
- * Asynchronous fchown(2) - Change ownership of a file.
- * @param fd A file descriptor.
- */
- export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace fchown {
- /**
- * Asynchronous fchown(2) - Change ownership of a file.
- * @param fd A file descriptor.
- */
- function __promisify__(fd: number, uid: number, gid: number): Promise;
- }
-
- /**
- * Synchronous fchown(2) - Change ownership of a file.
- * @param fd A file descriptor.
- */
- export function fchownSync(fd: number, uid: number, gid: number): void;
-
- /**
- * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace lchown {
- /**
- * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike, uid: number, gid: number): Promise;
- }
-
- /**
- * Synchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function lchownSync(path: PathLike, uid: number, gid: number): void;
-
- /**
- * Asynchronous chmod(2) - Change permissions of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace chmod {
- /**
- * Asynchronous chmod(2) - Change permissions of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- function __promisify__(path: PathLike, mode: Mode): Promise;
- }
-
- /**
- * Synchronous chmod(2) - Change permissions of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function chmodSync(path: PathLike, mode: Mode): void;
-
- /**
- * Asynchronous fchmod(2) - Change permissions of a file.
- * @param fd A file descriptor.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace fchmod {
- /**
- * Asynchronous fchmod(2) - Change permissions of a file.
- * @param fd A file descriptor.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- function __promisify__(fd: number, mode: Mode): Promise;
- }
-
- /**
- * Synchronous fchmod(2) - Change permissions of a file.
- * @param fd A file descriptor.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function fchmodSync(fd: number, mode: Mode): void;
-
- /**
- * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace lchmod {
- /**
- * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- function __promisify__(path: PathLike, mode: Mode): Promise;
- }
-
- /**
- * Synchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
- */
- export function lchmodSync(path: PathLike, mode: Mode): void;
-
- /**
- * Asynchronous stat(2) - Get file status.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace stat {
- /**
- * Asynchronous stat(2) - Get file status.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike): Promise;
- }
-
- /**
- * Synchronous stat(2) - Get file status.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function statSync(path: PathLike): Stats;
-
- /**
- * Asynchronous fstat(2) - Get file status.
- * @param fd A file descriptor.
- */
- export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace fstat {
- /**
- * Asynchronous fstat(2) - Get file status.
- * @param fd A file descriptor.
- */
- function __promisify__(fd: number): Promise;
- }
-
- /**
- * Synchronous fstat(2) - Get file status.
- * @param fd A file descriptor.
- */
- export function fstatSync(fd: number): Stats;
-
- /**
- * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace lstat {
- /**
- * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike): Promise;
- }
-
- /**
- * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function lstatSync(path: PathLike): Stats;
-
- /**
- * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
- * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace link {
- /**
- * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
- * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(existingPath: PathLike, newPath: PathLike): Promise;
- }
-
- /**
- * Synchronous link(2) - Create a new link (also known as a hard link) to an existing file.
- * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function linkSync(existingPath: PathLike, newPath: PathLike): void;
-
- /**
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
- * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
- * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
- */
- export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
-
- /**
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
- */
- export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace symlink {
- /**
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
- * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
- * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
- */
- function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise;
-
- type Type = "dir" | "file" | "junction";
- }
-
- /**
- * Synchronous symlink(2) - Create a new symbolic link to an existing file.
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
- * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
- * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
- */
- export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlink(
- path: PathLike,
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
- ): void;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlink(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace readlink {
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise;
-
- /**
- * Asynchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise;
- }
-
- /**
- * Synchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
-
- /**
- * Synchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
-
- /**
- * Synchronous readlink(2) - read value of a symbolic link.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpath(
- path: PathLike,
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
- ): void;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpath(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace realpath {
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise;
-
- /**
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise;
-
- function native(
- path: PathLike,
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
- ): void;
- function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
- function native(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
- function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
- }
-
- /**
- * Synchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
-
- /**
- * Synchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
-
- /**
- * Synchronous realpath(3) - return the canonicalized absolute pathname.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function realpathSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
-
- export namespace realpathSync {
- function native(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
- function native(path: PathLike, options: BufferEncodingOption): Buffer;
- function native(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
- }
-
- /**
- * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function unlink(path: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace unlink {
- /**
- * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike): Promise;
- }
-
- /**
- * Synchronous unlink(2) - delete a name and possibly the file it refers to.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function unlinkSync(path: PathLike): void;
-
- export interface RmDirOptions {
- /**
- * If `true`, perform a recursive directory removal. In
- * recursive mode, errors are not reported if `path` does not exist, and
- * operations are retried on failure.
- * @experimental
- * @default false
- */
- recursive?: boolean;
- }
-
- export interface RmDirAsyncOptions extends RmDirOptions {
- /**
- * The amount of time in milliseconds to wait between retries.
- * This option is ignored if the `recursive` option is not `true`.
- * @default 100
- */
- retryDelay?: number;
- /**
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
- * number of retries. This option is ignored if the `recursive` option is not
- * `true`.
- * @default 0
- */
- maxRetries?: number;
- }
-
- /**
- * Asynchronous rmdir(2) - delete a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function rmdir(path: PathLike, callback: NoParamCallback): void;
- export function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace rmdir {
- /**
- * Asynchronous rmdir(2) - delete a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise;
- }
-
- /**
- * Synchronous rmdir(2) - delete a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
-
- export interface MakeDirectoryOptions {
- /**
- * Indicates whether parent folders should be created.
- * If a folder was created, the path to the first created folder will be returned.
- * @default false
- */
- recursive?: boolean;
- /**
- * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
- * @default 0o777
- */
- mode?: Mode;
- }
-
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path: string) => void): void;
-
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
-
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path: string | undefined) => void): void;
-
- /**
- * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function mkdir(path: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace mkdir {
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise;
-
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise;
-
- /**
- * Asynchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise;
- }
-
- /**
- * Synchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string;
-
- /**
- * Synchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
-
- /**
- * Synchronous mkdir(2) - create a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
- */
- export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtemp(prefix: string, options: BaseEncodingOptions | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtemp(prefix: string, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- */
- export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace mkdtemp {
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(prefix: string, options: BufferEncodingOption): Promise;
-
- /**
- * Asynchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise;
- }
-
- /**
- * Synchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string;
-
- /**
- * Synchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
-
- /**
- * Synchronously creates a unique temporary directory.
- * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdir(
- path: PathLike,
- options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
- ): void;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdir(
- path: PathLike,
- options: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
- ): void;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
- */
- export function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace readdir {
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false }): Promise;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- function __promisify__(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): Promise;
-
- /**
- * Asynchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
- */
- function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise;
- }
-
- /**
- * Synchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
-
- /**
- * Synchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
-
- /**
- * Synchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
- */
- export function readdirSync(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): string[] | Buffer[];
-
- /**
- * Synchronous readdir(3) - read a directory.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
- */
- export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[];
-
- /**
- * Asynchronous close(2) - close a file descriptor.
- * @param fd A file descriptor.
- */
- export function close(fd: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace close {
- /**
- * Asynchronous close(2) - close a file descriptor.
- * @param fd A file descriptor.
- */
- function __promisify__(fd: number): Promise;
- }
-
- /**
- * Synchronous close(2) - close a file descriptor.
- * @param fd A file descriptor.
- */
- export function closeSync(fd: number): void;
-
- /**
- * Asynchronous open(2) - open and possibly create a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
- */
- export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
-
- /**
- * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- */
- export function open(path: PathLike, flags: OpenMode, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace open {
- /**
- * Asynchronous open(2) - open and possibly create a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
- */
- function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise;
- }
-
- /**
- * Synchronous open(2) - open and possibly create a file, returning a file descriptor..
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
- */
- export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
-
- /**
- * Asynchronously change file timestamps of the file referenced by the supplied path.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace utimes {
- /**
- * Asynchronously change file timestamps of the file referenced by the supplied path.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise;
- }
-
- /**
- * Synchronously change file timestamps of the file referenced by the supplied path.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
-
- /**
- * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace futimes {
- /**
- * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise;
- }
-
- /**
- * Synchronously change file timestamps of the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param atime The last access time. If a string is provided, it will be coerced to number.
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
- */
- export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
-
- /**
- * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
- * @param fd A file descriptor.
- */
- export function fsync(fd: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace fsync {
- /**
- * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
- * @param fd A file descriptor.
- */
- function __promisify__(fd: number): Promise;
- }
-
- /**
- * Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
- * @param fd A file descriptor.
- */
- export function fsyncSync(fd: number): void;
-
- /**
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- */
- export function write(
- fd: number,
- buffer: TBuffer,
- offset: number | undefined | null,
- length: number | undefined | null,
- position: number | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
- ): void;
-
- /**
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
- */
- export function write(
- fd: number,
- buffer: TBuffer,
- offset: number | undefined | null,
- length: number | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
- ): void;
-
- /**
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
- */
- export function write(
- fd: number,
- buffer: TBuffer,
- offset: number | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
- ): void;
-
- /**
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- */
- export function write(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
-
- /**
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param string A string to write.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- * @param encoding The expected string encoding.
- */
- export function write(
- fd: number,
- string: string,
- position: number | undefined | null,
- encoding: BufferEncoding | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
- ): void;
-
- /**
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param string A string to write.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- */
- export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
-
- /**
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param string A string to write.
- */
- export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace write {
- /**
- * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- */
- function __promisify__(
- fd: number,
- buffer?: TBuffer,
- offset?: number,
- length?: number,
- position?: number | null,
- ): Promise<{ bytesWritten: number, buffer: TBuffer }>;
-
- /**
- * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param string A string to write.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- * @param encoding The expected string encoding.
- */
- function __promisify__(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): Promise<{ bytesWritten: number, buffer: string }>;
- }
-
- /**
- * Synchronously writes `buffer` to the file referenced by the supplied file descriptor, returning the number of bytes written.
- * @param fd A file descriptor.
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- */
- export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
-
- /**
- * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
- * @param fd A file descriptor.
- * @param string A string to write.
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
- * @param encoding The expected string encoding.
- */
- export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
-
- /**
- * Asynchronously reads data from the file referenced by the supplied file descriptor.
- * @param fd A file descriptor.
- * @param buffer The buffer that the data will be written to.
- * @param offset The offset in the buffer at which to start writing.
- * @param length The number of bytes to read.
- * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
- */
- export function read(
- fd: number,
- buffer: TBuffer,
- offset: number,
- length: number,
- position: number | null,
- callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
- ): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace read {
- /**
- * @param fd A file descriptor.
- * @param buffer The buffer that the data will be written to.
- * @param offset The offset in the buffer at which to start writing.
- * @param length The number of bytes to read.
- * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
- */
- function __promisify__(
- fd: number,
- buffer: TBuffer,
- offset: number,
- length: number,
- position: number | null
- ): Promise<{ bytesRead: number, buffer: TBuffer }>;
- }
-
- export interface ReadSyncOptions {
- /**
- * @default 0
- */
- offset?: number;
- /**
- * @default `length of buffer`
- */
- length?: number;
- /**
- * @default null
- */
- position?: number | null;
- }
-
- /**
- * Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
- * @param fd A file descriptor.
- * @param buffer The buffer that the data will be written to.
- * @param offset The offset in the buffer at which to start writing.
- * @param length The number of bytes to read.
- * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
- */
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
-
- /**
- * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
- * If no `options` object is specified, it will default with the above values.
- */
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options An object that may contain an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- export function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- export function readFile(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- export function readFile(
- path: PathLike | number,
- options: BaseEncodingOptions & { flag?: string; } | string | undefined | null,
- callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
- ): void;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- */
- export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace readFile {
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options An object that may contain an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- function __promisify__(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Promise;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- function __promisify__(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string): Promise;
-
- /**
- * Asynchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- function __promisify__(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | string | null): Promise;
- }
-
- /**
- * Synchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
- */
- export function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
-
- /**
- * Synchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- export function readFileSync(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | BufferEncoding): string;
-
- /**
- * Synchronously reads the entire contents of a file.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
- * If a flag is not provided, it defaults to `'r'`.
- */
- export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | BufferEncoding | null): string | Buffer;
-
- export type WriteFileOptions = BaseEncodingOptions & { mode?: Mode; flag?: string; } | string | null;
-
- /**
- * Asynchronously writes data to a file, replacing the file if it already exists.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'w'` is used.
- */
- export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
-
- /**
- * Asynchronously writes data to a file, replacing the file if it already exists.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- */
- export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace writeFile {
- /**
- * Asynchronously writes data to a file, replacing the file if it already exists.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'w'` is used.
- */
- function __promisify__(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise;
- }
-
- /**
- * Synchronously writes data to a file, replacing the file if it already exists.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'w'` is used.
- */
- export function writeFileSync(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
-
- /**
- * Asynchronously append data to a file, creating the file if it does not exist.
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'a'` is used.
- */
- export function appendFile(file: PathLike | number, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
-
- /**
- * Asynchronously append data to a file, creating the file if it does not exist.
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- */
- export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace appendFile {
- /**
- * Asynchronously append data to a file, creating the file if it does not exist.
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'a'` is used.
- */
- function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise;
- }
-
- /**
- * Synchronously append data to a file, creating the file if it does not exist.
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
- * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `mode` is not supplied, the default of `0o666` is used.
- * If `mode` is a string, it is parsed as an octal integer.
- * If `flag` is not supplied, the default of `'a'` is used.
- */
- export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void;
-
- /**
- * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
- */
- export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
-
- /**
- * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
-
- /**
- * Stop watching for changes on `filename`.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
-
- /**
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `persistent` is not supplied, the default of `true` is used.
- * If `recursive` is not supplied, the default of `false` is used.
- */
- export function watch(
- filename: PathLike,
- options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null,
- listener?: (event: string, filename: string) => void,
- ): FSWatcher;
-
- /**
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `persistent` is not supplied, the default of `true` is used.
- * If `recursive` is not supplied, the default of `false` is used.
- */
- export function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
-
- /**
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
- * If `encoding` is not supplied, the default of `'utf8'` is used.
- * If `persistent` is not supplied, the default of `true` is used.
- * If `recursive` is not supplied, the default of `false` is used.
- */
- export function watch(
- filename: PathLike,
- options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | string | null,
- listener?: (event: string, filename: string | Buffer) => void,
- ): FSWatcher;
-
- /**
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
-
- /**
- * Asynchronously tests whether or not the given path exists by checking with the file system.
- * @deprecated since v1.0.0 Use `fs.stat()` or `fs.access()` instead
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function exists(path: PathLike, callback: (exists: boolean) => void): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace exists {
- /**
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- function __promisify__(path: PathLike): Promise;
- }
-
- /**
- * Synchronously tests whether or not the given path exists by checking with the file system.
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function existsSync(path: PathLike): boolean;
-
- export namespace constants {
- // File Access Constants
-
- /** Constant for fs.access(). File is visible to the calling process. */
- const F_OK: number;
-
- /** Constant for fs.access(). File can be read by the calling process. */
- const R_OK: number;
-
- /** Constant for fs.access(). File can be written by the calling process. */
- const W_OK: number;
-
- /** Constant for fs.access(). File can be executed by the calling process. */
- const X_OK: number;
-
- // File Copy Constants
-
- /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
- const COPYFILE_EXCL: number;
-
- /**
- * Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
- * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
- */
- const COPYFILE_FICLONE: number;
-
- /**
- * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
- * If the underlying platform does not support copy-on-write, then the operation will fail with an error.
- */
- const COPYFILE_FICLONE_FORCE: number;
-
- // File Open Constants
-
- /** Constant for fs.open(). Flag indicating to open a file for read-only access. */
- const O_RDONLY: number;
-
- /** Constant for fs.open(). Flag indicating to open a file for write-only access. */
- const O_WRONLY: number;
-
- /** Constant for fs.open(). Flag indicating to open a file for read-write access. */
- const O_RDWR: number;
-
- /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
- const O_CREAT: number;
-
- /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
- const O_EXCL: number;
-
- /**
- * Constant for fs.open(). Flag indicating that if path identifies a terminal device,
- * opening the path shall not cause that terminal to become the controlling terminal for the process
- * (if the process does not already have one).
- */
- const O_NOCTTY: number;
-
- /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
- const O_TRUNC: number;
-
- /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
- const O_APPEND: number;
-
- /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
- const O_DIRECTORY: number;
-
- /**
- * constant for fs.open().
- * Flag indicating reading accesses to the file system will no longer result in
- * an update to the atime information associated with the file.
- * This flag is available on Linux operating systems only.
- */
- const O_NOATIME: number;
-
- /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
- const O_NOFOLLOW: number;
-
- /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
- const O_SYNC: number;
-
- /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
- const O_DSYNC: number;
-
- /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
- const O_SYMLINK: number;
-
- /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
- const O_DIRECT: number;
-
- /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
- const O_NONBLOCK: number;
-
- // File Type Constants
-
- /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
- const S_IFMT: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
- const S_IFREG: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
- const S_IFDIR: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
- const S_IFCHR: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
- const S_IFBLK: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
- const S_IFIFO: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
- const S_IFLNK: number;
-
- /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
- const S_IFSOCK: number;
-
- // File Mode Constants
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
- const S_IRWXU: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
- const S_IRUSR: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
- const S_IWUSR: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
- const S_IXUSR: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
- const S_IRWXG: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
- const S_IRGRP: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
- const S_IWGRP: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
- const S_IXGRP: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
- const S_IRWXO: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
- const S_IROTH: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
- const S_IWOTH: number;
-
- /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
- const S_IXOTH: number;
-
- /**
- * When set, a memory file mapping is used to access the file. This flag
- * is available on Windows operating systems only. On other operating systems,
- * this flag is ignored.
- */
- const UV_FS_O_FILEMAP: number;
- }
-
- /**
- * Asynchronously tests a user's permissions for the file specified by path.
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
-
- /**
- * Asynchronously tests a user's permissions for the file specified by path.
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function access(path: PathLike, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace access {
- /**
- * Asynchronously tests a user's permissions for the file specified by path.
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- function __promisify__(path: PathLike, mode?: number): Promise;
- }
-
- /**
- * Synchronously tests a user's permissions for the file specified by path.
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function accessSync(path: PathLike, mode?: number): void;
-
- /**
- * Returns a new `ReadStream` object.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function createReadStream(path: PathLike, options?: string | {
- flags?: string;
- encoding?: BufferEncoding;
- fd?: number;
- mode?: number;
- autoClose?: boolean;
- /**
- * @default false
- */
- emitClose?: boolean;
- start?: number;
- end?: number;
- highWaterMark?: number;
- }): ReadStream;
-
- /**
- * Returns a new `WriteStream` object.
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
- * URL support is _experimental_.
- */
- export function createWriteStream(path: PathLike, options?: string | {
- flags?: string;
- encoding?: BufferEncoding;
- fd?: number;
- mode?: number;
- autoClose?: boolean;
- emitClose?: boolean;
- start?: number;
- highWaterMark?: number;
- }): WriteStream;
-
- /**
- * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
- * @param fd A file descriptor.
- */
- export function fdatasync(fd: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace fdatasync {
- /**
- * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
- * @param fd A file descriptor.
- */
- function __promisify__(fd: number): Promise;
- }
-
- /**
- * Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
- * @param fd A file descriptor.
- */
- export function fdatasyncSync(fd: number): void;
-
- /**
- * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
- * No arguments other than a possible exception are given to the callback function.
- * Node.js makes no guarantees about the atomicity of the copy operation.
- * If an error occurs after the destination file has been opened for writing, Node.js will attempt
- * to remove the destination.
- * @param src A path to the source file.
- * @param dest A path to the destination file.
- */
- export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
- /**
- * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
- * No arguments other than a possible exception are given to the callback function.
- * Node.js makes no guarantees about the atomicity of the copy operation.
- * If an error occurs after the destination file has been opened for writing, Node.js will attempt
- * to remove the destination.
- * @param src A path to the source file.
- * @param dest A path to the destination file.
- * @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
- */
- export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
-
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
- export namespace copyFile {
- /**
- * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
- * No arguments other than a possible exception are given to the callback function.
- * Node.js makes no guarantees about the atomicity of the copy operation.
- * If an error occurs after the destination file has been opened for writing, Node.js will attempt
- * to remove the destination.
- * @param src A path to the source file.
- * @param dest A path to the destination file.
- * @param flags An optional integer that specifies the behavior of the copy operation.
- * The only supported flag is fs.constants.COPYFILE_EXCL,
- * which causes the copy operation to fail if dest already exists.
- */
- function __promisify__(src: PathLike, dst: PathLike, flags?: number): Promise;
- }
-
- /**
- * Synchronously copies src to dest. By default, dest is overwritten if it already exists.
- * Node.js makes no guarantees about the atomicity of the copy operation.
- * If an error occurs after the destination file has been opened for writing, Node.js will attempt
- * to remove the destination.
- * @param src A path to the source file.
- * @param dest A path to the destination file.
- * @param flags An optional integer that specifies the behavior of the copy operation.
- * The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
- */
- export function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
-
- /**
- * Write an array of ArrayBufferViews to the file specified by fd using writev().
- * position is the offset from the beginning of the file where this data should be written.
- * It is unsafe to use fs.writev() multiple times on the same file without waiting for the callback. For this scenario, use fs.createWriteStream().
- * On Linux, positional writes don't work when the file is opened in append mode.
- * The kernel ignores the position argument and always appends the data to the end of the file.
- */
- export function writev(
- fd: number,
- buffers: NodeJS.ArrayBufferView[],
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
- ): void;
- export function writev(
- fd: number,
- buffers: NodeJS.ArrayBufferView[],
- position: number,
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
- ): void;
-
- export interface WriteVResult {
- bytesWritten: number;
- buffers: NodeJS.ArrayBufferView[];
- }
-
- export namespace writev {
- function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise;
- }
-
- /**
- * See `writev`.
- */
- export function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
-
- export function readv(
- fd: number,
- buffers: NodeJS.ArrayBufferView[],
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
- ): void;
- export function readv(
- fd: number,
- buffers: NodeJS.ArrayBufferView[],
- position: number,
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
- ): void;
-
- export interface ReadVResult {
- bytesRead: number;
- buffers: NodeJS.ArrayBufferView[];
- }
-
- export namespace readv {
- function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise;
- }
-
- /**
- * See `readv`.
- */
- export function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
-
- export interface OpenDirOptions {
- encoding?: BufferEncoding;
- /**
- * Number of directory entries that are buffered
- * internally when reading from the directory. Higher values lead to better
- * performance but higher memory usage.
- * @default 32
- */
- bufferSize?: number;
- }
-
- export function opendirSync(path: string, options?: OpenDirOptions): Dir;
-
- export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
- export function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
-
- export namespace opendir {
- function __promisify__(path: string, options?: OpenDirOptions): Promise;
- }
-}
diff --git a/types/node/ts3.1/globals.d.ts b/types/node/ts3.1/globals.d.ts
deleted file mode 100644
index b7dc6241df..0000000000
--- a/types/node/ts3.1/globals.d.ts
+++ /dev/null
@@ -1,598 +0,0 @@
-// Declare "static" methods in Error
-interface ErrorConstructor {
- /** Create .stack property on a target object */
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
-
- /**
- * Optional override for formatting stack traces
- *
- * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces
- */
- prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
-
- stackTraceLimit: number;
-}
-
-// Node.js ESNEXT support
-interface String {
- /** Removes whitespace from the left end of a string. */
- trimLeft(): string;
- /** Removes whitespace from the right end of a string. */
- trimRight(): string;
-
- /** Returns a copy with leading whitespace removed. */
- trimStart(): string;
- /** Returns a copy with trailing whitespace removed. */
- trimEnd(): string;
-}
-
-interface ImportMeta {
- url: string;
-}
-
-/*-----------------------------------------------*
- * *
- * GLOBAL *
- * *
- ------------------------------------------------*/
-
-// For backwards compability
-interface NodeRequire extends NodeJS.Require {}
-interface RequireResolve extends NodeJS.RequireResolve {}
-interface NodeModule extends NodeJS.Module {}
-
-declare var process: NodeJS.Process;
-declare var console: Console;
-
-declare var __filename: string;
-declare var __dirname: string;
-
-declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
-declare namespace setTimeout {
- function __promisify__(ms: number): Promise;
- function __promisify__(ms: number, value: T): Promise;
-}
-declare function clearTimeout(timeoutId: NodeJS.Timeout): void;
-declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
-declare function clearInterval(intervalId: NodeJS.Timeout): void;
-declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
-declare namespace setImmediate {
- function __promisify__(): Promise;
- function __promisify__(value: T): Promise;
-}
-declare function clearImmediate(immediateId: NodeJS.Immediate): void;
-
-declare function queueMicrotask(callback: () => void): void;
-
-declare var require: NodeRequire;
-declare var module: NodeModule;
-
-// Same as module.exports
-declare var exports: any;
-
-// Buffer class
-type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
-
-/**
- * Raw data is stored in instances of the Buffer class.
- * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
- * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
- */
-declare class Buffer extends Uint8Array {
- /**
- * Allocates a new buffer containing the given {str}.
- *
- * @param str String to store in buffer.
- * @param encoding encoding to use, optional. Default is 'utf8'
- * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
- */
- constructor(str: string, encoding?: BufferEncoding);
- /**
- * Allocates a new buffer of {size} octets.
- *
- * @param size count of octets to allocate.
- * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
- */
- constructor(size: number);
- /**
- * Allocates a new buffer containing the given {array} of octets.
- *
- * @param array The octets to store.
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
- */
- constructor(array: Uint8Array);
- /**
- * Produces a Buffer backed by the same allocated memory as
- * the given {ArrayBuffer}/{SharedArrayBuffer}.
- *
- *
- * @param arrayBuffer The ArrayBuffer with which to share memory.
- * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
- */
- constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
- /**
- * Allocates a new buffer containing the given {array} of octets.
- *
- * @param array The octets to store.
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
- */
- constructor(array: any[]);
- /**
- * Copies the passed {buffer} data onto a new {Buffer} instance.
- *
- * @param buffer The buffer to copy.
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
- */
- constructor(buffer: Buffer);
- /**
- * When passed a reference to the .buffer property of a TypedArray instance,
- * the newly created Buffer will share the same allocated memory as the TypedArray.
- * The optional {byteOffset} and {length} arguments specify a memory range
- * within the {arrayBuffer} that will be shared by the Buffer.
- *
- * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
- */
- static from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
- /**
- * Creates a new Buffer using the passed {data}
- * @param data data to create a new Buffer
- */
- static from(data: number[]): Buffer;
- static from(data: Uint8Array): Buffer;
- /**
- * Creates a new buffer containing the coerced value of an object
- * A `TypeError` will be thrown if {obj} has not mentioned methods or is not of other type appropriate for `Buffer.from()` variants.
- * @param obj An object supporting `Symbol.toPrimitive` or `valueOf()`.
- */
- static from(obj: { valueOf(): string | object } | { [Symbol.toPrimitive](hint: 'string'): string }, byteOffset?: number, length?: number): Buffer;
- /**
- * Creates a new Buffer containing the given JavaScript string {str}.
- * If provided, the {encoding} parameter identifies the character encoding.
- * If not provided, {encoding} defaults to 'utf8'.
- */
- static from(str: string, encoding?: BufferEncoding): Buffer;
- /**
- * Creates a new Buffer using the passed {data}
- * @param values to create a new Buffer
- */
- static of(...items: number[]): Buffer;
- /**
- * Returns true if {obj} is a Buffer
- *
- * @param obj object to test.
- */
- static isBuffer(obj: any): obj is Buffer;
- /**
- * Returns true if {encoding} is a valid encoding argument.
- * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
- *
- * @param encoding string to test.
- */
- static isEncoding(encoding: string): encoding is BufferEncoding;
- /**
- * Gives the actual byte length of a string. encoding defaults to 'utf8'.
- * This is not the same as String.prototype.length since that returns the number of characters in a string.
- *
- * @param string string to test.
- * @param encoding encoding used to evaluate (defaults to 'utf8')
- */
- static byteLength(
- string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
- encoding?: BufferEncoding
- ): number;
- /**
- * Returns a buffer which is the result of concatenating all the buffers in the list together.
- *
- * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
- * If the list has exactly one item, then the first item of the list is returned.
- * If the list has more than one item, then a new Buffer is created.
- *
- * @param list An array of Buffer objects to concatenate
- * @param totalLength Total length of the buffers when concatenated.
- * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
- */
- static concat(list: Uint8Array[], totalLength?: number): Buffer;
- /**
- * The same as buf1.compare(buf2).
- */
- static compare(buf1: Uint8Array, buf2: Uint8Array): number;
- /**
- * Allocates a new buffer of {size} octets.
- *
- * @param size count of octets to allocate.
- * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
- * If parameter is omitted, buffer will be filled with zeros.
- * @param encoding encoding used for call to buf.fill while initalizing
- */
- static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
- /**
- * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
- * of the newly created Buffer are unknown and may contain sensitive data.
- *
- * @param size count of octets to allocate
- */
- static allocUnsafe(size: number): Buffer;
- /**
- * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
- * of the newly created Buffer are unknown and may contain sensitive data.
- *
- * @param size count of octets to allocate
- */
- static allocUnsafeSlow(size: number): Buffer;
- /**
- * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
- */
- static poolSize: number;
-
- write(string: string, encoding?: BufferEncoding): number;
- write(string: string, offset: number, encoding?: BufferEncoding): number;
- write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
- toString(encoding?: BufferEncoding, start?: number, end?: number): string;
- toJSON(): { type: 'Buffer'; data: number[] };
- equals(otherBuffer: Uint8Array): boolean;
- compare(
- otherBuffer: Uint8Array,
- targetStart?: number,
- targetEnd?: number,
- sourceStart?: number,
- sourceEnd?: number
- ): number;
- copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
- /**
- * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
- *
- * This method is incompatible with `Uint8Array#slice()`, which returns a copy of the original memory.
- *
- * @param begin Where the new `Buffer` will start. Default: `0`.
- * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
- */
- slice(begin?: number, end?: number): Buffer;
- /**
- * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
- *
- * This method is compatible with `Uint8Array#subarray()`.
- *
- * @param begin Where the new `Buffer` will start. Default: `0`.
- * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
- */
- subarray(begin?: number, end?: number): Buffer;
- writeUIntLE(value: number, offset: number, byteLength: number): number;
- writeUIntBE(value: number, offset: number, byteLength: number): number;
- writeIntLE(value: number, offset: number, byteLength: number): number;
- writeIntBE(value: number, offset: number, byteLength: number): number;
- readUIntLE(offset: number, byteLength: number): number;
- readUIntBE(offset: number, byteLength: number): number;
- readIntLE(offset: number, byteLength: number): number;
- readIntBE(offset: number, byteLength: number): number;
- readUInt8(offset?: number): number;
- readUInt16LE(offset?: number): number;
- readUInt16BE(offset?: number): number;
- readUInt32LE(offset?: number): number;
- readUInt32BE(offset?: number): number;
- readInt8(offset?: number): number;
- readInt16LE(offset?: number): number;
- readInt16BE(offset?: number): number;
- readInt32LE(offset?: number): number;
- readInt32BE(offset?: number): number;
- readFloatLE(offset?: number): number;
- readFloatBE(offset?: number): number;
- readDoubleLE(offset?: number): number;
- readDoubleBE(offset?: number): number;
- reverse(): this;
- swap16(): Buffer;
- swap32(): Buffer;
- swap64(): Buffer;
- writeUInt8(value: number, offset?: number): number;
- writeUInt16LE(value: number, offset?: number): number;
- writeUInt16BE(value: number, offset?: number): number;
- writeUInt32LE(value: number, offset?: number): number;
- writeUInt32BE(value: number, offset?: number): number;
- writeInt8(value: number, offset?: number): number;
- writeInt16LE(value: number, offset?: number): number;
- writeInt16BE(value: number, offset?: number): number;
- writeInt32LE(value: number, offset?: number): number;
- writeInt32BE(value: number, offset?: number): number;
- writeFloatLE(value: number, offset?: number): number;
- writeFloatBE(value: number, offset?: number): number;
- writeDoubleLE(value: number, offset?: number): number;
- writeDoubleBE(value: number, offset?: number): number;
-
- fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
-
- indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
- lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
- entries(): IterableIterator<[number, number]>;
- includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
- keys(): IterableIterator;
- values(): IterableIterator;
-}
-
-/*----------------------------------------------*
-* *
-* GLOBAL INTERFACES *
-* *
-*-----------------------------------------------*/
-declare namespace NodeJS {
- interface InspectOptions {
- /**
- * If set to `true`, getters are going to be
- * inspected as well. If set to `'get'` only getters without setter are going
- * to be inspected. If set to `'set'` only getters having a corresponding
- * setter are going to be inspected. This might cause side effects depending on
- * the getter function.
- * @default `false`
- */
- getters?: 'get' | 'set' | boolean;
- showHidden?: boolean;
- /**
- * @default 2
- */
- depth?: number | null;
- colors?: boolean;
- customInspect?: boolean;
- showProxy?: boolean;
- maxArrayLength?: number | null;
- /**
- * Specifies the maximum number of characters to
- * include when formatting. Set to `null` or `Infinity` to show all elements.
- * Set to `0` or negative to show no characters.
- * @default Infinity
- */
- maxStringLength?: number | null;
- breakLength?: number;
- /**
- * Setting this to `false` causes each object key
- * to be displayed on a new line. It will also add new lines to text that is
- * longer than `breakLength`. If set to a number, the most `n` inner elements
- * are united on a single line as long as all properties fit into
- * `breakLength`. Short array elements are also grouped together. Note that no
- * text will be reduced below 16 characters, no matter the `breakLength` size.
- * For more information, see the example below.
- * @default `true`
- */
- compact?: boolean | number;
- sorted?: boolean | ((a: string, b: string) => number);
- }
-
- interface CallSite {
- /**
- * Value of "this"
- */
- getThis(): any;
-
- /**
- * Type of "this" as a string.
- * This is the name of the function stored in the constructor field of
- * "this", if available. Otherwise the object's [[Class]] internal
- * property.
- */
- getTypeName(): string | null;
-
- /**
- * Current function
- */
- getFunction(): Function | undefined;
-
- /**
- * Name of the current function, typically its name property.
- * If a name property is not available an attempt will be made to try
- * to infer a name from the function's context.
- */
- getFunctionName(): string | null;
-
- /**
- * Name of the property [of "this" or one of its prototypes] that holds
- * the current function
- */
- getMethodName(): string | null;
-
- /**
- * Name of the script [if this function was defined in a script]
- */
- getFileName(): string | null;
-
- /**
- * Current line number [if this function was defined in a script]
- */
- getLineNumber(): number | null;
-
- /**
- * Current column number [if this function was defined in a script]
- */
- getColumnNumber(): number | null;
-
- /**
- * A call site object representing the location where eval was called
- * [if this function was created using a call to eval]
- */
- getEvalOrigin(): string | undefined;
-
- /**
- * Is this a toplevel invocation, that is, is "this" the global object?
- */
- isToplevel(): boolean;
-
- /**
- * Does this call take place in code defined by a call to eval?
- */
- isEval(): boolean;
-
- /**
- * Is this call in native V8 code?
- */
- isNative(): boolean;
-
- /**
- * Is this a constructor call?
- */
- isConstructor(): boolean;
- }
-
- interface ErrnoException extends Error {
- errno?: number;
- code?: string;
- path?: string;
- syscall?: string;
- stack?: string;
- }
-
- interface ReadableStream extends EventEmitter {
- readable: boolean;
- read(size?: number): string | Buffer;
- setEncoding(encoding: BufferEncoding): this;
- pause(): this;
- resume(): this;
- isPaused(): boolean;
- pipe(destination: T, options?: { end?: boolean; }): T;
- unpipe(destination?: WritableStream): this;
- unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
- wrap(oldStream: ReadableStream): this;
- [Symbol.asyncIterator](): AsyncIterableIterator;
- }
-
- interface WritableStream extends EventEmitter {
- writable: boolean;
- write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
- write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
- end(cb?: () => void): void;
- end(data: string | Uint8Array, cb?: () => void): void;
- end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
- }
-
- interface ReadWriteStream extends ReadableStream, WritableStream { }
-
- interface Global {
- Array: typeof Array;
- ArrayBuffer: typeof ArrayBuffer;
- Boolean: typeof Boolean;
- Buffer: typeof Buffer;
- DataView: typeof DataView;
- Date: typeof Date;
- Error: typeof Error;
- EvalError: typeof EvalError;
- Float32Array: typeof Float32Array;
- Float64Array: typeof Float64Array;
- Function: typeof Function;
- Infinity: typeof Infinity;
- Int16Array: typeof Int16Array;
- Int32Array: typeof Int32Array;
- Int8Array: typeof Int8Array;
- Intl: typeof Intl;
- JSON: typeof JSON;
- Map: MapConstructor;
- Math: typeof Math;
- NaN: typeof NaN;
- Number: typeof Number;
- Object: typeof Object;
- Promise: typeof Promise;
- RangeError: typeof RangeError;
- ReferenceError: typeof ReferenceError;
- RegExp: typeof RegExp;
- Set: SetConstructor;
- String: typeof String;
- Symbol: Function;
- SyntaxError: typeof SyntaxError;
- TypeError: typeof TypeError;
- URIError: typeof URIError;
- Uint16Array: typeof Uint16Array;
- Uint32Array: typeof Uint32Array;
- Uint8Array: typeof Uint8Array;
- Uint8ClampedArray: typeof Uint8ClampedArray;
- WeakMap: WeakMapConstructor;
- WeakSet: WeakSetConstructor;
- clearImmediate: (immediateId: Immediate) => void;
- clearInterval: (intervalId: Timeout) => void;
- clearTimeout: (timeoutId: Timeout) => void;
- decodeURI: typeof decodeURI;
- decodeURIComponent: typeof decodeURIComponent;
- encodeURI: typeof encodeURI;
- encodeURIComponent: typeof encodeURIComponent;
- escape: (str: string) => string;
- eval: typeof eval;
- global: Global;
- isFinite: typeof isFinite;
- isNaN: typeof isNaN;
- parseFloat: typeof parseFloat;
- parseInt: typeof parseInt;
- setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
- setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
- setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
- queueMicrotask: typeof queueMicrotask;
- undefined: typeof undefined;
- unescape: (str: string) => string;
- gc: () => void;
- v8debug?: any;
- }
-
- interface RefCounted {
- ref(): this;
- unref(): this;
- }
-
- // compatibility with older typings
- interface Timer extends RefCounted {
- hasRef(): boolean;
- refresh(): this;
- }
-
- interface Immediate extends RefCounted {
- hasRef(): boolean;
- _onImmediate: Function; // to distinguish it from the Timeout class
- }
-
- interface Timeout extends Timer {
- hasRef(): boolean;
- refresh(): this;
- }
-
- type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
- type ArrayBufferView = TypedArray | DataView;
-
- interface Require {
- /* tslint:disable-next-line:callable-types */
- (id: string): any;
- resolve: RequireResolve;
- cache: Dict;
- /**
- * @deprecated
- */
- extensions: RequireExtensions;
- main: Module | undefined;
- }
-
- interface RequireResolve {
- (id: string, options?: { paths?: string[]; }): string;
- paths(request: string): string[] | null;
- }
-
- interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
- '.js': (m: Module, filename: string) => any;
- '.json': (m: Module, filename: string) => any;
- '.node': (m: Module, filename: string) => any;
- }
- interface Module {
- exports: any;
- require: Require;
- id: string;
- filename: string;
- loaded: boolean;
- /** @deprecated since 14.6.0 Please use `require.main` and `module.children` instead. */
- parent: Module | null | undefined;
- children: Module[];
- /**
- * @since 11.14.0
- *
- * The directory name of the module. This is usually the same as the path.dirname() of the module.id.
- */
- path: string;
- paths: string[];
- }
-
- interface Dict {
- [key: string]: T | undefined;
- }
-
- interface ReadOnlyDict {
- readonly [key: string]: T | undefined;
- }
-}
diff --git a/types/node/ts3.1/index.d.ts b/types/node/ts3.1/index.d.ts
deleted file mode 100644
index 79b58d9ec5..0000000000
--- a/types/node/ts3.1/index.d.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-// NOTE: These definitions support NodeJS and TypeScript 3.1.
-
-// NOTE: TypeScript version-specific augmentations can be found in the following paths:
-// - ~/base.d.ts - Shared definitions common to all TypeScript versions
-// - ~/index.d.ts - Definitions specific to TypeScript 2.8
-// - ~/ts3.5/index.d.ts - Definitions specific to TypeScript 3.5
-
-// NOTE: Augmentations for TypeScript 3.5 and later should use individual files for overrides
-// within the respective ~/ts3.5 (or later) folder. However, this is disallowed for versions
-// prior to TypeScript 3.5, so the older definitions will be found here.
-
-// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
-///
-
-// We can't include globals.global.d.ts in globals.d.ts, as it'll cause duplication errors in TypeScript 3.5+
-///
-
-// We can't include assert.d.ts in base.d.ts, as it'll cause duplication errors in TypeScript 3.7+
-///
-
-// Forward-declarations for needed types from es2015 and later (in case users are using `--lib es5`)
-// Empty interfaces are used here which merge fine with the real declarations in the lib XXX files
-// just to ensure the names are known and node typings can be used without importing these libs.
-// if someone really needs these types the libs need to be added via --lib or in tsconfig.json
-interface AsyncIterable { }
-interface IterableIterator { }
-interface AsyncIterableIterator {}
-interface SymbolConstructor {
- readonly asyncIterator: symbol;
-}
-declare var Symbol: SymbolConstructor;
-// even this is just a forward declaration some properties are added otherwise
-// it would be allowed to pass anything to e.g. Buffer.from()
-interface SharedArrayBuffer {
- readonly byteLength: number;
- slice(begin?: number, end?: number): SharedArrayBuffer;
-}
-
-declare module "util" {
- namespace types {
- function isBigInt64Array(value: any): boolean;
- function isBigUint64Array(value: any): boolean;
- }
-}
diff --git a/types/node/ts3.1/node-tests.ts b/types/node/ts3.1/node-tests.ts
deleted file mode 100644
index f8b9c6cbf8..0000000000
--- a/types/node/ts3.1/node-tests.ts
+++ /dev/null
@@ -1,353 +0,0 @@
-import * as fs from "fs";
-import * as url from "url";
-import * as util from "util";
-import * as http from "http";
-import * as https from "https";
-import * as net from "net";
-import * as console2 from "console";
-import * as timers from "timers";
-import * as inspector from "inspector";
-import * as trace_events from "trace_events";
-
-//////////////////////////////////////////////////////
-/// Https tests : http://nodejs.org/api/https.html ///
-//////////////////////////////////////////////////////
-
-{
- let agent: https.Agent = new https.Agent({
- keepAlive: true,
- keepAliveMsecs: 10000,
- maxSockets: Infinity,
- maxFreeSockets: 256,
- maxCachedSessions: 100,
- timeout: 15000
- });
-
- agent = https.globalAgent;
-
- let sockets: NodeJS.ReadOnlyDict = agent.sockets;
- sockets = agent.freeSockets;
-
- https.request({
- agent: false
- });
- https.request({
- agent
- });
- https.request({
- agent: undefined
- });
-
- https.get('http://www.example.com/xyz');
- https.request('http://www.example.com/xyz');
-
- https.get('http://www.example.com/xyz', (res: http.IncomingMessage): void => {});
- https.request('http://www.example.com/xyz', (res: http.IncomingMessage): void => {});
-
- https.get(new url.URL('http://www.example.com/xyz'));
- https.request(new url.URL('http://www.example.com/xyz'));
-
- https.get(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {});
- https.request(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {});
-
- const opts: https.RequestOptions = {
- path: '/some/path'
- };
- https.get(new url.URL('http://www.example.com'), opts);
- https.request(new url.URL('http://www.example.com'), opts);
- https.get(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {});
- https.request(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {});
-
- https.globalAgent.options.ca = [];
-
- {
- function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {}
-
- class MyIncomingMessage extends http.IncomingMessage {
- foo: number;
- }
-
- class MyServerResponse extends http.ServerResponse {
- foo: string;
- }
-
- let server: https.Server;
-
- server = new https.Server();
- server = new https.Server(reqListener);
- server = new https.Server({ IncomingMessage: MyIncomingMessage});
-
- server = new https.Server({
- IncomingMessage: MyIncomingMessage,
- ServerResponse: MyServerResponse
- }, reqListener);
-
- server = https.createServer();
- server = https.createServer(reqListener);
- server = https.createServer({ IncomingMessage: MyIncomingMessage });
- server = https.createServer({ ServerResponse: MyServerResponse }, reqListener);
-
- const timeout: number = server.timeout;
- const listening: boolean = server.listening;
- const keepAliveTimeout: number = server.keepAliveTimeout;
- const maxHeadersCount: number | null = server.maxHeadersCount;
- const headersTimeout: number = server.headersTimeout;
- server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
- }
-}
-
-/////////////////////////////////////////////////////
-/// Timers tests : https://nodejs.org/api/timers.html
-/////////////////////////////////////////////////////
-
-{
- {
- const immediate = timers
- .setImmediate(() => {
- console.log('immediate');
- })
- .unref()
- .ref();
- const b: boolean = immediate.hasRef();
- timers.clearImmediate(immediate);
- }
- {
- const timeout = timers
- .setInterval(() => {
- console.log('interval');
- }, 20)
- .unref()
- .ref()
- .refresh();
- const b: boolean = timeout.hasRef();
- timers.clearInterval(timeout);
- }
- {
- const timeout = timers
- .setTimeout(() => {
- console.log('timeout');
- }, 20)
- .unref()
- .ref()
- .refresh();
- const b: boolean = timeout.hasRef();
- timers.clearTimeout(timeout);
- }
- async function testPromisify(doSomething: {
- (foo: any, onSuccessCallback: (result: string) => void, onErrorCallback: (reason: any) => void): void;
- [util.promisify.custom](foo: any): Promise;
- }) {
- const setTimeout = util.promisify(timers.setTimeout);
- let v: void = await setTimeout(100); // tslint:disable-line no-void-expression void-return
- let s: string = await setTimeout(100, "");
-
- const setImmediate = util.promisify(timers.setImmediate);
- v = await setImmediate(); // tslint:disable-line no-void-expression
- s = await setImmediate("");
-
- // $ExpectType (foo: any) => Promise
- const doSomethingPromise = util.promisify(doSomething);
-
- // $ExpectType string
- s = await doSomethingPromise('foo');
- }
-}
-
-/////////////////////////////////////////////////////////
-/// Errors Tests : https://nodejs.org/api/errors.html ///
-/////////////////////////////////////////////////////////
-
-{
- {
- Error.stackTraceLimit = Infinity;
- }
- {
- const myObject = {};
- Error.captureStackTrace(myObject);
- }
- {
- const frames: NodeJS.CallSite[] = [];
- Error.prepareStackTrace!(new Error(), frames);
- }
- {
- const frame: NodeJS.CallSite = null!;
- const frameThis: any = frame.getThis();
- const typeName: string | null = frame.getTypeName();
- const func: Function | undefined = frame.getFunction();
- const funcName: string | null = frame.getFunctionName();
- const meth: string | null = frame.getMethodName();
- const fname: string | null = frame.getFileName();
- const lineno: number | null = frame.getLineNumber();
- const colno: number | null = frame.getColumnNumber();
- const evalOrigin: string | undefined = frame.getEvalOrigin();
- const isTop: boolean = frame.isToplevel();
- const isEval: boolean = frame.isEval();
- const isNative: boolean = frame.isNative();
- const isConstr: boolean = frame.isConstructor();
- }
-}
-
-///////////////////////////////////////////////////////////
-/// Console Tests : https://nodejs.org/api/console.html ///
-///////////////////////////////////////////////////////////
-
-{
- {
- let _c: Console = console;
- _c = console2;
- }
- {
- const writeStream = fs.createWriteStream('./index.d.ts');
- let consoleInstance: Console = new console.Console(writeStream);
-
- consoleInstance = new console.Console(writeStream, writeStream);
- consoleInstance = new console.Console(writeStream, writeStream, true);
- consoleInstance = new console.Console({
- stdout: writeStream,
- stderr: writeStream,
- colorMode: 'auto',
- ignoreErrors: true
- });
- consoleInstance = new console.Console({
- stdout: writeStream,
- colorMode: false
- });
- consoleInstance = new console.Console({
- stdout: writeStream
- });
- }
- {
- console.assert('value');
- console.assert('value', 'message');
- console.assert('value', 'message', 'foo', 'bar');
- console.clear();
- console.count();
- console.count('label');
- console.countReset();
- console.countReset('label');
- console.debug();
- console.debug('message');
- console.debug('message', 'foo', 'bar');
- console.dir('obj');
- console.dir('obj', { depth: 1 });
- console.error();
- console.error('message');
- console.error('message', 'foo', 'bar');
- console.group();
- console.group('label');
- console.group('label1', 'label2');
- console.groupCollapsed();
- console.groupEnd();
- console.info();
- console.info('message');
- console.info('message', 'foo', 'bar');
- console.log();
- console.log('message');
- console.log('message', 'foo', 'bar');
- console.table({ foo: 'bar' });
- console.table([{ foo: 'bar' }]);
- console.table([{ foo: 'bar' }], ['foo']);
- console.time();
- console.time('label');
- console.timeEnd();
- console.timeEnd('label');
- console.timeLog();
- console.timeLog('label');
- console.timeLog('label', 'foo', 'bar');
- console.trace();
- console.trace('message');
- console.trace('message', 'foo', 'bar');
- console.warn();
- console.warn('message');
- console.warn('message', 'foo', 'bar');
-
- // --- Inspector mode only ---
- console.profile();
- console.profile('label');
- console.profileEnd();
- console.profileEnd('label');
- console.timeStamp();
- console.timeStamp('label');
- }
-}
-
-/*****************************************************************************
- * *
- * The following tests are the modules not mentioned in document but existed *
- * *
- *****************************************************************************/
-
-///////////////////////////////////////////////////////////
-/// Inspector Tests ///
-///////////////////////////////////////////////////////////
-
-{
- {
- const b: inspector.Console.ConsoleMessage = {source: 'test', text: 'test', level: 'error' };
- inspector.open();
- inspector.open(0);
- inspector.open(0, 'localhost');
- inspector.open(0, 'localhost', true);
- inspector.close();
- const inspectorUrl: string | undefined = inspector.url();
-
- const session = new inspector.Session();
- session.connect();
- session.disconnect();
-
- // Unknown post method
- session.post('A.b', { key: 'value' }, (err, params) => {});
- // TODO: parameters are implicitly 'any' and need type annotation
- session.post('A.b', (err: Error | null, params?: {}) => {});
- session.post('A.b');
- // Known post method
- const parameter: inspector.Runtime.EvaluateParameterType = { expression: '2 + 2' };
- session.post('Runtime.evaluate', parameter,
- (err: Error | null, params: inspector.Runtime.EvaluateReturnType) => {});
- session.post('Runtime.evaluate', (err: Error, params: inspector.Runtime.EvaluateReturnType) => {
- const exceptionDetails: inspector.Runtime.ExceptionDetails = params.exceptionDetails!;
- const resultClassName: string = params.result.className!;
- });
- session.post('Runtime.evaluate');
-
- // General event
- session.on('inspectorNotification', message => {
- message; // $ExpectType InspectorNotification<{}>
- });
- // Known events
- session.on('Debugger.paused', (message: inspector.InspectorNotification) => {
- const method: string = message.method;
- const pauseReason: string = message.params.reason;
- });
- session.on('Debugger.resumed', () => {});
- // Node Inspector events
- session.on('NodeTracing.dataCollected', (message: inspector.InspectorNotification) => {
- const value: Array<{}> = message.params.value;
- });
- }
-}
-
-///////////////////////////////////////////////////////////
-/// Trace Events Tests ///
-///////////////////////////////////////////////////////////
-
-{
- const enabledCategories: string | undefined = trace_events.getEnabledCategories();
- const tracing: trace_events.Tracing = trace_events.createTracing({ categories: ['node', 'v8'] });
- const categories: string = tracing.categories;
- const enabled: boolean = tracing.enabled;
- tracing.enable();
- tracing.disable();
-}
-
-////////////////////////////////////////////////////
-/// Node.js ESNEXT Support
-////////////////////////////////////////////////////
-
-{
- const s = 'foo';
- const s1: string = s.trimLeft();
- const s2: string = s.trimRight();
- const s3: string = s.trimStart();
- const s4: string = s.trimEnd();
-}
diff --git a/types/node/ts3.1/process.d.ts b/types/node/ts3.1/process.d.ts
deleted file mode 100644
index d9267e4fb9..0000000000
--- a/types/node/ts3.1/process.d.ts
+++ /dev/null
@@ -1,405 +0,0 @@
-declare module "process" {
- import * as tty from "tty";
-
- global {
- var process: NodeJS.Process;
-
- namespace NodeJS {
- // this namespace merge is here because these are specifically used
- // as the type for process.stdin, process.stdout, and process.stderr.
- // they can't live in tty.d.ts because we need to disambiguate the imported name.
- interface ReadStream extends tty.ReadStream {}
- interface WriteStream extends tty.WriteStream {}
-
- interface MemoryUsage {
- rss: number;
- heapTotal: number;
- heapUsed: number;
- external: number;
- arrayBuffers: number;
- }
-
- interface CpuUsage {
- user: number;
- system: number;
- }
-
- interface ProcessRelease {
- name: string;
- sourceUrl?: string;
- headersUrl?: string;
- libUrl?: string;
- lts?: string;
- }
-
- interface ProcessVersions extends Dict {
- http_parser: string;
- node: string;
- v8: string;
- ares: string;
- uv: string;
- zlib: string;
- modules: string;
- openssl: string;
- }
-
- type Platform = 'aix'
- | 'android'
- | 'darwin'
- | 'freebsd'
- | 'linux'
- | 'openbsd'
- | 'sunos'
- | 'win32'
- | 'cygwin'
- | 'netbsd';
-
- type Signals =
- "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
- "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
- "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
- "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
-
- type MultipleResolveType = 'resolve' | 'reject';
-
- type BeforeExitListener = (code: number) => void;
- type DisconnectListener = () => void;
- type ExitListener = (code: number) => void;
- type RejectionHandledListener = (promise: Promise) => void;
- type UncaughtExceptionListener = (error: Error) => void;
- type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise) => void;
- type WarningListener = (warning: Error) => void;
- type MessageListener = (message: any, sendHandle: any) => void;
- type SignalsListener = (signal: Signals) => void;
- type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
- type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
- type MultipleResolveListener = (type: MultipleResolveType, promise: Promise, value: any) => void;
-
- interface Socket extends ReadWriteStream {
- isTTY?: true;
- }
-
- // Alias for compatibility
- interface ProcessEnv extends Dict {}
-
- interface HRTime {
- (time?: [number, number]): [number, number];
- }
-
- interface ProcessReport {
- /**
- * Directory where the report is written.
- * working directory of the Node.js process.
- * @default '' indicating that reports are written to the current
- */
- directory: string;
-
- /**
- * Filename where the report is written.
- * The default value is the empty string.
- * @default '' the output filename will be comprised of a timestamp,
- * PID, and sequence number.
- */
- filename: string;
-
- /**
- * Returns a JSON-formatted diagnostic report for the running process.
- * The report's JavaScript stack trace is taken from err, if present.
- */
- getReport(err?: Error): string;
-
- /**
- * If true, a diagnostic report is generated on fatal errors,
- * such as out of memory errors or failed C++ assertions.
- * @default false
- */
- reportOnFatalError: boolean;
-
- /**
- * If true, a diagnostic report is generated when the process
- * receives the signal specified by process.report.signal.
- * @defaul false
- */
- reportOnSignal: boolean;
-
- /**
- * If true, a diagnostic report is generated on uncaught exception.
- * @default false
- */
- reportOnUncaughtException: boolean;
-
- /**
- * The signal used to trigger the creation of a diagnostic report.
- * @default 'SIGUSR2'
- */
- signal: Signals;
-
- /**
- * Writes a diagnostic report to a file. If filename is not provided, the default filename
- * includes the date, time, PID, and a sequence number.
- * The report's JavaScript stack trace is taken from err, if present.
- *
- * @param fileName Name of the file where the report is written.
- * This should be a relative path, that will be appended to the directory specified in
- * `process.report.directory`, or the current working directory of the Node.js process,
- * if unspecified.
- * @param error A custom error used for reporting the JavaScript stack.
- * @return Filename of the generated report.
- */
- writeReport(fileName?: string): string;
- writeReport(error?: Error): string;
- writeReport(fileName?: string, err?: Error): string;
- }
-
- interface ResourceUsage {
- fsRead: number;
- fsWrite: number;
- involuntaryContextSwitches: number;
- ipcReceived: number;
- ipcSent: number;
- majorPageFault: number;
- maxRSS: number;
- minorPageFault: number;
- sharedMemorySize: number;
- signalsCount: number;
- swappedOut: number;
- systemCPUTime: number;
- unsharedDataSize: number;
- unsharedStackSize: number;
- userCPUTime: number;
- voluntaryContextSwitches: number;
- }
-
- interface Process extends EventEmitter {
- /**
- * Can also be a tty.WriteStream, not typed due to limitations.
- */
- stdout: WriteStream & {
- fd: 1;
- };
- /**
- * Can also be a tty.WriteStream, not typed due to limitations.
- */
- stderr: WriteStream & {
- fd: 2;
- };
- stdin: ReadStream & {
- fd: 0;
- };
- openStdin(): Socket;
- argv: string[];
- argv0: string;
- execArgv: string[];
- execPath: string;
- abort(): void;
- chdir(directory: string): void;
- cwd(): string;
- debugPort: number;
- emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
- env: ProcessEnv;
- exit(code?: number): never;
- exitCode?: number;
- getgid(): number;
- setgid(id: number | string): void;
- getuid(): number;
- setuid(id: number | string): void;
- geteuid(): number;
- seteuid(id: number | string): void;
- getegid(): number;
- setegid(id: number | string): void;
- getgroups(): number[];
- setgroups(groups: Array): void;
- setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
- hasUncaughtExceptionCaptureCallback(): boolean;
- version: string;
- versions: ProcessVersions;
- config: {
- target_defaults: {
- cflags: any[];
- default_configuration: string;
- defines: string[];
- include_dirs: string[];
- libraries: string[];
- };
- variables: {
- clang: number;
- host_arch: string;
- node_install_npm: boolean;
- node_install_waf: boolean;
- node_prefix: string;
- node_shared_openssl: boolean;
- node_shared_v8: boolean;
- node_shared_zlib: boolean;
- node_use_dtrace: boolean;
- node_use_etw: boolean;
- node_use_openssl: boolean;
- target_arch: string;
- v8_no_strict_aliasing: number;
- v8_use_snapshot: boolean;
- visibility: string;
- };
- };
- kill(pid: number, signal?: string | number): true;
- pid: number;
- ppid: number;
- title: string;
- arch: string;
- platform: Platform;
- /** @deprecated since v14.0.0 - use `require.main` instead. */
- mainModule?: Module;
- memoryUsage(): MemoryUsage;
- cpuUsage(previousValue?: CpuUsage): CpuUsage;
- nextTick(callback: Function, ...args: any[]): void;
- release: ProcessRelease;
- features: {
- inspector: boolean;
- debug: boolean;
- uv: boolean;
- ipv6: boolean;
- tls_alpn: boolean;
- tls_sni: boolean;
- tls_ocsp: boolean;
- tls: boolean;
- };
- /**
- * @deprecated since v14.0.0 - Calling process.umask() with no argument causes
- * the process-wide umask to be written twice. This introduces a race condition between threads,
- * and is a potential security vulnerability. There is no safe, cross-platform alternative API.
- */
- umask(): number;
- /**
- * Can only be set if not in worker thread.
- */
- umask(mask: number): number;
- uptime(): number;
- hrtime: HRTime;
- domain: Domain;
-
- // Worker
- send?(message: any, sendHandle?: any, options?: { swallowErrors?: boolean}, callback?: (error: Error | null) => void): boolean;
- disconnect(): void;
- connected: boolean;
-
- /**
- * The `process.allowedNodeEnvironmentFlags` property is a special,
- * read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
- * environment variable.
- */
- allowedNodeEnvironmentFlags: ReadonlySet;
-
- /**
- * Only available with `--experimental-report`
- */
- report?: ProcessReport;
-
- resourceUsage(): ResourceUsage;
-
- /* EventEmitter */
- addListener(event: "beforeExit", listener: BeforeExitListener): this;
- addListener(event: "disconnect", listener: DisconnectListener): this;
- addListener(event: "exit", listener: ExitListener): this;
- addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
- addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
- addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
- addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
- addListener(event: "warning", listener: WarningListener): this;
- addListener(event: "message", listener: MessageListener): this;
- addListener(event: Signals, listener: SignalsListener): this;
- addListener(event: "newListener", listener: NewListenerListener): this;
- addListener(event: "removeListener", listener: RemoveListenerListener): this;
- addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
-
- emit(event: "beforeExit", code: number): boolean;
- emit(event: "disconnect"): boolean;
- emit(event: "exit", code: number): boolean;
- emit(event: "rejectionHandled", promise: Promise): boolean;
- emit(event: "uncaughtException", error: Error): boolean;
- emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
- emit(event: "unhandledRejection", reason: any, promise: Promise): boolean;
- emit(event: "warning", warning: Error): boolean;
- emit(event: "message", message: any, sendHandle: any): this;
- emit(event: Signals, signal: Signals): boolean;
- emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
- emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
- emit(event: "multipleResolves", listener: MultipleResolveListener): this;
-
- on(event: "beforeExit", listener: BeforeExitListener): this;
- on(event: "disconnect", listener: DisconnectListener): this;
- on(event: "exit", listener: ExitListener): this;
- on(event: "rejectionHandled", listener: RejectionHandledListener): this;
- on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
- on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
- on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
- on(event: "warning", listener: WarningListener): this;
- on(event: "message", listener: MessageListener): this;
- on(event: Signals, listener: SignalsListener): this;
- on(event: "newListener", listener: NewListenerListener): this;
- on(event: "removeListener", listener: RemoveListenerListener): this;
- on(event: "multipleResolves", listener: MultipleResolveListener): this;
- on(event: string | symbol, listener: (...args: any[]) => void): this;
-
- once(event: "beforeExit", listener: BeforeExitListener): this;
- once(event: "disconnect", listener: DisconnectListener): this;
- once(event: "exit", listener: ExitListener): this;
- once(event: "rejectionHandled", listener: RejectionHandledListener): this;
- once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
- once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
- once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
- once(event: "warning", listener: WarningListener): this;
- once(event: "message", listener: MessageListener): this;
- once(event: Signals, listener: SignalsListener): this;
- once(event: "newListener", listener: NewListenerListener): this;
- once(event: "removeListener", listener: RemoveListenerListener): this;
- once(event: "multipleResolves", listener: MultipleResolveListener): this;
-
- prependListener(event: "beforeExit", listener: BeforeExitListener): this;
- prependListener(event: "disconnect", listener: DisconnectListener): this;
- prependListener(event: "exit", listener: ExitListener): this;
- prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
- prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
- prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
- prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
- prependListener(event: "warning", listener: WarningListener): this;
- prependListener(event: "message", listener: MessageListener): this;
- prependListener(event: Signals, listener: SignalsListener): this;
- prependListener(event: "newListener", listener: NewListenerListener): this;
- prependListener(event: "removeListener", listener: RemoveListenerListener): this;
- prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
-
- prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
- prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
- prependOnceListener(event: "exit", listener: ExitListener): this;
- prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
- prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
- prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
- prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
- prependOnceListener(event: "warning", listener: WarningListener): this;
- prependOnceListener(event: "message", listener: MessageListener): this;
- prependOnceListener(event: Signals, listener: SignalsListener): this;
- prependOnceListener(event: "newListener", listener: NewListenerListener): this;
- prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
- prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
-
- listeners(event: "beforeExit"): BeforeExitListener[];
- listeners(event: "disconnect"): DisconnectListener[];
- listeners(event: "exit"): ExitListener[];
- listeners(event: "rejectionHandled"): RejectionHandledListener[];
- listeners(event: "uncaughtException"): UncaughtExceptionListener[];
- listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
- listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
- listeners(event: "warning"): WarningListener[];
- listeners(event: "message"): MessageListener[];
- listeners(event: Signals): SignalsListener[];
- listeners(event: "newListener"): NewListenerListener[];
- listeners(event: "removeListener"): RemoveListenerListener[];
- listeners(event: "multipleResolves"): MultipleResolveListener[];
- }
-
- interface Global {
- process: Process;
- }
- }
- }
-
- export = process;
-}
diff --git a/types/node/ts3.1/tsconfig.json b/types/node/ts3.1/tsconfig.json
deleted file mode 100644
index cc6def6c6d..0000000000
--- a/types/node/ts3.1/tsconfig.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "files": [
- "index.d.ts",
- "node-tests.ts"
- ],
- "compilerOptions": {
- "module": "commonjs",
- "target": "esnext",
- "lib": [
- "es6",
- "dom"
- ],
- "noImplicitAny": true,
- "noImplicitThis": true,
- "strictNullChecks": true,
- "strictFunctionTypes": true,
- "baseUrl": "../../",
- "typeRoots": [
- "../../"
- ],
- "types": [],
- "noEmit": true,
- "forceConsistentCasingInFileNames": true
- }
-}
diff --git a/types/node/ts3.1/tslint.json b/types/node/ts3.1/tslint.json
deleted file mode 100644
index 65e8b18d2a..0000000000
--- a/types/node/ts3.1/tslint.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "dtslint/dt.json",
- "rules": {
- "ban-types": false,
- "no-bad-reference": false,
- "no-empty-interface": false,
- "no-single-declare-module": false,
- "unified-signatures": false
- }
-}
diff --git a/types/node/ts3.1/util.d.ts b/types/node/ts3.1/util.d.ts
deleted file mode 100644
index 542ad76524..0000000000
--- a/types/node/ts3.1/util.d.ts
+++ /dev/null
@@ -1,194 +0,0 @@
-declare module "util" {
- interface InspectOptions extends NodeJS.InspectOptions { }
- type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
- type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
- interface InspectOptionsStylized extends InspectOptions {
- stylize(text: string, styleType: Style): string;
- }
- function format(format: any, ...param: any[]): string;
- function formatWithOptions(inspectOptions: InspectOptions, format: string, ...param: any[]): string;
- /** @deprecated since v0.11.3 - use a third party module instead. */
- function log(string: string): void;
- function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
- function inspect(object: any, options: InspectOptions): string;
- namespace inspect {
- let colors: NodeJS.Dict<[number, number]>;
- let styles: {
- [K in Style]: string
- };
- let defaultOptions: InspectOptions;
- /**
- * Allows changing inspect settings from the repl.
- */
- let replDefaults: InspectOptions;
- const custom: unique symbol;
- }
- /** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
- function isArray(object: any): object is any[];
- /** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
- function isRegExp(object: any): object is RegExp;
- /** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
- function isDate(object: any): object is Date;
- /** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
- function isError(object: any): object is Error;
- function inherits(constructor: any, superConstructor: any): void;
- function debuglog(key: string): (msg: string, ...param: any[]) => void;
- /** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
- function isBoolean(object: any): object is boolean;
- /** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
- function isBuffer(object: any): object is Buffer;
- /** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
- function isFunction(object: any): boolean;
- /** @deprecated since v4.0.0 - use `value === null` instead. */
- function isNull(object: any): object is null;
- /** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
- function isNullOrUndefined(object: any): object is null | undefined;
- /** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
- function isNumber(object: any): object is number;
- /** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
- function isObject(object: any): boolean;
- /** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
- function isPrimitive(object: any): boolean;
- /** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
- function isString(object: any): object is string;
- /** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
- function isSymbol(object: any): object is symbol;
- /** @deprecated since v4.0.0 - use `value === undefined` instead. */
- function isUndefined(object: any): object is undefined;
- function deprecate(fn: T, message: string, code?: string): T;
- function isDeepStrictEqual(val1: any, val2: any): boolean;
-
- function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
- function callbackify(fn: (arg1: T1) => Promise): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(fn: (arg1: T1) => Promise): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
- function callbackify(fn: (arg1: T1, arg2: T2) => Promise): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(fn: (arg1: T1, arg2: T2) => Promise): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
- function callbackify(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3) => Promise): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise,
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise,
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
- function callbackify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
-
- interface CustomPromisifyLegacy extends Function {
- __promisify__: TCustom;
- }
-
- interface CustomPromisifySymbol extends Function {
- [promisify.custom]: TCustom;
- }
-
- type CustomPromisify = CustomPromisifySymbol | CustomPromisifyLegacy;
-
- function promisify(fn: CustomPromisify): TCustom;
- function promisify(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise;
- function promisify(fn: (callback: (err?: any) => void) => void): () => Promise;
- function promisify(fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void): (arg1: T1) => Promise;
- function promisify(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise;
- function promisify(fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise;
- function promisify(fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2) => Promise;
- function promisify(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void):
- (arg1: T1, arg2: T2, arg3: T3) => Promise;
- function promisify(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise;
- function promisify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise;
- function promisify(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void):
- (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise;
- function promisify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise;
- function promisify(
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
- ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise;
- function promisify(fn: Function): Function;
- namespace promisify {
- const custom: unique symbol;
- }
-
- namespace types {
- function isAnyArrayBuffer(object: any): boolean;
- function isArgumentsObject(object: any): object is IArguments;
- function isArrayBuffer(object: any): object is ArrayBuffer;
- function isArrayBufferView(object: any): object is ArrayBufferView;
- function isAsyncFunction(object: any): boolean;
- function isBooleanObject(object: any): object is Boolean;
- function isBoxedPrimitive(object: any): object is (Number | Boolean | String | Symbol /* | Object(BigInt) | Object(Symbol) */);
- function isDataView(object: any): object is DataView;
- function isDate(object: any): object is Date;
- function isExternal(object: any): boolean;
- function isFloat32Array(object: any): object is Float32Array;
- function isFloat64Array(object: any): object is Float64Array;
- function isGeneratorFunction(object: any): boolean;
- function isGeneratorObject(object: any): boolean;
- function isInt8Array(object: any): object is Int8Array;
- function isInt16Array(object: any): object is Int16Array;
- function isInt32Array(object: any): object is Int32Array;
- function isMap(object: any): boolean;
- function isMapIterator(object: any): boolean;
- function isModuleNamespaceObject(value: any): boolean;
- function isNativeError(object: any): object is Error;
- function isNumberObject(object: any): object is Number;
- function isPromise(object: any): boolean;
- function isProxy(object: any): boolean;
- function isRegExp(object: any): object is RegExp;
- function isSet(object: any): boolean;
- function isSetIterator(object: any): boolean;
- function isSharedArrayBuffer(object: any): boolean;
- function isStringObject(object: any): boolean;
- function isSymbolObject(object: any): boolean;
- function isTypedArray(object: any): object is NodeJS.TypedArray;
- function isUint8Array(object: any): object is Uint8Array;
- function isUint8ClampedArray(object: any): object is Uint8ClampedArray;
- function isUint16Array(object: any): object is Uint16Array;
- function isUint32Array(object: any): object is Uint32Array;
- function isWeakMap(object: any): boolean;
- function isWeakSet(object: any): boolean;
- function isWebAssemblyCompiledModule(object: any): boolean;
- }
-
- class TextDecoder {
- readonly encoding: string;
- readonly fatal: boolean;
- readonly ignoreBOM: boolean;
- constructor(
- encoding?: string,
- options?: { fatal?: boolean; ignoreBOM?: boolean }
- );
- decode(
- input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
- options?: { stream?: boolean }
- ): string;
- }
-
- interface EncodeIntoResult {
- /**
- * The read Unicode code units of input.
- */
-
- read: number;
- /**
- * The written UTF-8 bytes of output.
- */
- written: number;
- }
-
- class TextEncoder {
- readonly encoding: string;
- encode(input?: string): Uint8Array;
- encodeInto(input: string, output: Uint8Array): EncodeIntoResult;
- }
-}
diff --git a/types/node/ts3.1/assert.d.ts b/types/node/ts3.4/assert.d.ts
similarity index 100%
rename from types/node/ts3.1/assert.d.ts
rename to types/node/ts3.4/assert.d.ts
diff --git a/types/node/ts3.4/base.d.ts b/types/node/ts3.4/base.d.ts
index 4b315049d1..2ea04f58fc 100644
--- a/types/node/ts3.4/base.d.ts
+++ b/types/node/ts3.4/base.d.ts
@@ -13,11 +13,44 @@
///
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
-// tslint:disable-next-line:no-bad-reference
-///
-// TypeScript 3.2-specific augmentations:
-///
-///
-///
///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
diff --git a/types/node/ts3.1/globals.global.d.ts b/types/node/ts3.4/globals.global.d.ts
similarity index 100%
rename from types/node/ts3.1/globals.global.d.ts
rename to types/node/ts3.4/globals.global.d.ts
diff --git a/types/node/ts3.4/index.d.ts b/types/node/ts3.4/index.d.ts
index a9c9defebb..506b32a598 100644
--- a/types/node/ts3.4/index.d.ts
+++ b/types/node/ts3.4/index.d.ts
@@ -4,9 +4,5 @@
// Typically type modifiations should be made in base.d.ts instead of here
///
-
-// tslint:disable-next-line:no-bad-reference
-///
-
-// tslint:disable-next-line:no-bad-reference
-///
+///
+///
diff --git a/types/node/ts3.4/node-tests.ts b/types/node/ts3.4/node-tests.ts
index 56f949002e..7c0caab463 100644
--- a/types/node/ts3.4/node-tests.ts
+++ b/types/node/ts3.4/node-tests.ts
@@ -1,31 +1,356 @@
-// tslint:disable-next-line:no-bad-reference
-import '../ts3.1/node-tests';
-import '../ts3.1/assert';
-import '../ts3.1/buffer';
-import '../ts3.1/child_process';
-import '../ts3.1/cluster';
-import '../ts3.1/crypto';
-import '../ts3.1/dgram';
-import '../ts3.1/global';
-import '../ts3.1/http';
-import '../ts3.1/http2';
-import '../ts3.1/net';
-import '../ts3.1/os';
-import '../ts3.1/path';
-import '../ts3.1/perf_hooks';
-import '../ts3.1/process';
-import '../ts3.1/querystring';
-import '../ts3.1/readline';
-import '../ts3.1/repl';
-import '../ts3.1/stream';
-import '../ts3.1/tls';
-import '../ts3.1/tty';
-import '../ts3.1/util';
-import '../ts3.1/worker_threads';
-import '../ts3.1/zlib';
+import * as fs from "fs";
+import * as url from "url";
+import * as util from "util";
+import * as http from "http";
+import * as https from "https";
+import * as net from "net";
+import * as console2 from "console";
+import * as timers from "timers";
+import * as inspector from "inspector";
+import * as trace_events from "trace_events";
-import { types, promisify } from 'util';
-import { BigIntStats, statSync, Stats } from 'fs';
+//////////////////////////////////////////////////////
+/// Https tests : http://nodejs.org/api/https.html ///
+//////////////////////////////////////////////////////
+
+{
+ let agent: https.Agent = new https.Agent({
+ keepAlive: true,
+ keepAliveMsecs: 10000,
+ maxSockets: Infinity,
+ maxFreeSockets: 256,
+ maxCachedSessions: 100,
+ timeout: 15000
+ });
+
+ agent = https.globalAgent;
+
+ let sockets: NodeJS.ReadOnlyDict = agent.sockets;
+ sockets = agent.freeSockets;
+
+ https.request({
+ agent: false
+ });
+ https.request({
+ agent
+ });
+ https.request({
+ agent: undefined
+ });
+
+ https.get('http://www.example.com/xyz');
+ https.request('http://www.example.com/xyz');
+
+ https.get('http://www.example.com/xyz', (res: http.IncomingMessage): void => {});
+ https.request('http://www.example.com/xyz', (res: http.IncomingMessage): void => {});
+
+ https.get(new url.URL('http://www.example.com/xyz'));
+ https.request(new url.URL('http://www.example.com/xyz'));
+
+ https.get(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {});
+ https.request(new url.URL('http://www.example.com/xyz'), (res: http.IncomingMessage): void => {});
+
+ const opts: https.RequestOptions = {
+ path: '/some/path'
+ };
+ https.get(new url.URL('http://www.example.com'), opts);
+ https.request(new url.URL('http://www.example.com'), opts);
+ https.get(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {});
+ https.request(new url.URL('http://www.example.com/xyz'), opts, (res: http.IncomingMessage): void => {});
+
+ https.globalAgent.options.ca = [];
+
+ {
+ function reqListener(req: http.IncomingMessage, res: http.ServerResponse): void {}
+
+ class MyIncomingMessage extends http.IncomingMessage {
+ foo: number;
+ }
+
+ class MyServerResponse extends http.ServerResponse {
+ foo: string;
+ }
+
+ let server: https.Server;
+
+ server = new https.Server();
+ server = new https.Server(reqListener);
+ server = new https.Server({ IncomingMessage: MyIncomingMessage});
+
+ server = new https.Server({
+ IncomingMessage: MyIncomingMessage,
+ ServerResponse: MyServerResponse
+ }, reqListener);
+
+ server = https.createServer();
+ server = https.createServer(reqListener);
+ server = https.createServer({ IncomingMessage: MyIncomingMessage });
+ server = https.createServer({ ServerResponse: MyServerResponse }, reqListener);
+
+ const timeout: number = server.timeout;
+ const listening: boolean = server.listening;
+ const keepAliveTimeout: number = server.keepAliveTimeout;
+ const maxHeadersCount: number | null = server.maxHeadersCount;
+ const headersTimeout: number = server.headersTimeout;
+ server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
+ }
+}
+
+/////////////////////////////////////////////////////
+/// Timers tests : https://nodejs.org/api/timers.html
+/////////////////////////////////////////////////////
+
+{
+ {
+ const immediate = timers
+ .setImmediate(() => {
+ console.log('immediate');
+ })
+ .unref()
+ .ref();
+ const b: boolean = immediate.hasRef();
+ timers.clearImmediate(immediate);
+ }
+ {
+ const timeout = timers
+ .setInterval(() => {
+ console.log('interval');
+ }, 20)
+ .unref()
+ .ref()
+ .refresh();
+ const b: boolean = timeout.hasRef();
+ timers.clearInterval(timeout);
+ }
+ {
+ const timeout = timers
+ .setTimeout(() => {
+ console.log('timeout');
+ }, 20)
+ .unref()
+ .ref()
+ .refresh();
+ const b: boolean = timeout.hasRef();
+ timers.clearTimeout(timeout);
+ }
+ async function testPromisify(doSomething: {
+ (foo: any, onSuccessCallback: (result: string) => void, onErrorCallback: (reason: any) => void): void;
+ [util.promisify.custom](foo: any): Promise;
+ }) {
+ const setTimeout = util.promisify(timers.setTimeout);
+ let v: void = await setTimeout(100); // tslint:disable-line no-void-expression void-return
+ let s: string = await setTimeout(100, "");
+
+ const setImmediate = util.promisify(timers.setImmediate);
+ v = await setImmediate(); // tslint:disable-line no-void-expression
+ s = await setImmediate("");
+
+ // $ExpectType (foo: any) => Promise
+ const doSomethingPromise = util.promisify(doSomething);
+
+ // $ExpectType string
+ s = await doSomethingPromise('foo');
+ }
+}
+
+/////////////////////////////////////////////////////////
+/// Errors Tests : https://nodejs.org/api/errors.html ///
+/////////////////////////////////////////////////////////
+
+{
+ {
+ Error.stackTraceLimit = Infinity;
+ }
+ {
+ const myObject = {};
+ Error.captureStackTrace(myObject);
+ }
+ {
+ const frames: NodeJS.CallSite[] = [];
+ Error.prepareStackTrace!(new Error(), frames);
+ }
+ {
+ const frame: NodeJS.CallSite = null!;
+ const frameThis: any = frame.getThis();
+ const typeName: string | null = frame.getTypeName();
+ const func: Function | undefined = frame.getFunction();
+ const funcName: string | null = frame.getFunctionName();
+ const meth: string | null = frame.getMethodName();
+ const fname: string | null = frame.getFileName();
+ const lineno: number | null = frame.getLineNumber();
+ const colno: number | null = frame.getColumnNumber();
+ const evalOrigin: string | undefined = frame.getEvalOrigin();
+ const isTop: boolean = frame.isToplevel();
+ const isEval: boolean = frame.isEval();
+ const isNative: boolean = frame.isNative();
+ const isConstr: boolean = frame.isConstructor();
+ }
+}
+
+///////////////////////////////////////////////////////////
+/// Console Tests : https://nodejs.org/api/console.html ///
+///////////////////////////////////////////////////////////
+
+{
+ {
+ let _c: Console = console;
+ _c = console2;
+ }
+ {
+ const writeStream = fs.createWriteStream('./index.d.ts');
+ let consoleInstance: Console = new console.Console(writeStream);
+
+ consoleInstance = new console.Console(writeStream, writeStream);
+ consoleInstance = new console.Console(writeStream, writeStream, true);
+ consoleInstance = new console.Console({
+ stdout: writeStream,
+ stderr: writeStream,
+ colorMode: 'auto',
+ ignoreErrors: true
+ });
+ consoleInstance = new console.Console({
+ stdout: writeStream,
+ colorMode: false
+ });
+ consoleInstance = new console.Console({
+ stdout: writeStream
+ });
+ }
+ {
+ console.assert('value');
+ console.assert('value', 'message');
+ console.assert('value', 'message', 'foo', 'bar');
+ console.clear();
+ console.count();
+ console.count('label');
+ console.countReset();
+ console.countReset('label');
+ console.debug();
+ console.debug('message');
+ console.debug('message', 'foo', 'bar');
+ console.dir('obj');
+ console.dir('obj', { depth: 1 });
+ console.error();
+ console.error('message');
+ console.error('message', 'foo', 'bar');
+ console.group();
+ console.group('label');
+ console.group('label1', 'label2');
+ console.groupCollapsed();
+ console.groupEnd();
+ console.info();
+ console.info('message');
+ console.info('message', 'foo', 'bar');
+ console.log();
+ console.log('message');
+ console.log('message', 'foo', 'bar');
+ console.table({ foo: 'bar' });
+ console.table([{ foo: 'bar' }]);
+ console.table([{ foo: 'bar' }], ['foo']);
+ console.time();
+ console.time('label');
+ console.timeEnd();
+ console.timeEnd('label');
+ console.timeLog();
+ console.timeLog('label');
+ console.timeLog('label', 'foo', 'bar');
+ console.trace();
+ console.trace('message');
+ console.trace('message', 'foo', 'bar');
+ console.warn();
+ console.warn('message');
+ console.warn('message', 'foo', 'bar');
+
+ // --- Inspector mode only ---
+ console.profile();
+ console.profile('label');
+ console.profileEnd();
+ console.profileEnd('label');
+ console.timeStamp();
+ console.timeStamp('label');
+ }
+}
+
+/*****************************************************************************
+ * *
+ * The following tests are the modules not mentioned in document but existed *
+ * *
+ *****************************************************************************/
+
+///////////////////////////////////////////////////////////
+/// Inspector Tests ///
+///////////////////////////////////////////////////////////
+
+{
+ {
+ const b: inspector.Console.ConsoleMessage = {source: 'test', text: 'test', level: 'error' };
+ inspector.open();
+ inspector.open(0);
+ inspector.open(0, 'localhost');
+ inspector.open(0, 'localhost', true);
+ inspector.close();
+ const inspectorUrl: string | undefined = inspector.url();
+
+ const session = new inspector.Session();
+ session.connect();
+ session.disconnect();
+
+ // Unknown post method
+ session.post('A.b', { key: 'value' }, (err, params) => {});
+ // TODO: parameters are implicitly 'any' and need type annotation
+ session.post('A.b', (err: Error | null, params?: {}) => {});
+ session.post('A.b');
+ // Known post method
+ const parameter: inspector.Runtime.EvaluateParameterType = { expression: '2 + 2' };
+ session.post('Runtime.evaluate', parameter,
+ (err: Error | null, params: inspector.Runtime.EvaluateReturnType) => {});
+ session.post('Runtime.evaluate', (err: Error, params: inspector.Runtime.EvaluateReturnType) => {
+ const exceptionDetails: inspector.Runtime.ExceptionDetails = params.exceptionDetails!;
+ const resultClassName: string = params.result.className!;
+ });
+ session.post('Runtime.evaluate');
+
+ // General event
+ session.on('inspectorNotification', message => {
+ message; // $ExpectType InspectorNotification<{}>
+ });
+ // Known events
+ session.on('Debugger.paused', (message: inspector.InspectorNotification) => {
+ const method: string = message.method;
+ const pauseReason: string = message.params.reason;
+ });
+ session.on('Debugger.resumed', () => {});
+ // Node Inspector events
+ session.on('NodeTracing.dataCollected', (message: inspector.InspectorNotification) => {
+ const value: Array<{}> = message.params.value;
+ });
+ }
+}
+
+///////////////////////////////////////////////////////////
+/// Trace Events Tests ///
+///////////////////////////////////////////////////////////
+
+{
+ const enabledCategories: string | undefined = trace_events.getEnabledCategories();
+ const tracing: trace_events.Tracing = trace_events.createTracing({ categories: ['node', 'v8'] });
+ const categories: string = tracing.categories;
+ const enabled: boolean = tracing.enabled;
+ tracing.enable();
+ tracing.disable();
+}
+
+////////////////////////////////////////////////////
+/// Node.js ESNEXT Support
+////////////////////////////////////////////////////
+
+{
+ const s = 'foo';
+ const s1: string = s.trimLeft();
+ const s2: string = s.trimRight();
+ const s3: string = s.trimStart();
+ const s4: string = s.trimEnd();
+}
//////////////////////////////////////////////////////////
/// Global Tests : https://nodejs.org/api/global.html ///
@@ -39,10 +364,10 @@ import { BigIntStats, statSync, Stats } from 'fs';
// Util Tests
{
const value: BigInt64Array | BigUint64Array | number = [] as any;
- if (types.isBigInt64Array(value)) {
+ if (util.types.isBigInt64Array(value)) {
// $ExpectType BigInt64Array
const b = value;
- } else if (types.isBigUint64Array(value)) {
+ } else if (util.types.isBigUint64Array(value)) {
// $ExpectType BigUint64Array
const b = value;
} else {
@@ -50,15 +375,15 @@ import { BigIntStats, statSync, Stats } from 'fs';
const b = value;
}
- const arg1UnknownError: (arg: string) => Promise = promisify((arg: string, cb: (err: unknown, result: number) => void): void => { });
- const arg1AnyError: (arg: string) => Promise = promisify((arg: string, cb: (err: any, result: number) => void): void => { });
+ const arg1UnknownError: (arg: string) => Promise = util.promisify((arg: string, cb: (err: unknown, result: number) => void): void => { });
+ const arg1AnyError: (arg: string) => Promise = util.promisify((arg: string, cb: (err: any, result: number) => void): void => { });
}
// FS Tests
{
- const bigStats: BigIntStats = statSync('.', { bigint: true });
+ const bigStats: fs.BigIntStats = fs.statSync('.', { bigint: true });
const bigIntStat: bigint = bigStats.atimeNs;
- const anyStats: Stats | BigIntStats = statSync('.', { bigint: Math.random() > 0.5 });
+ const anyStats: fs.Stats | fs.BigIntStats = fs.statSync('.', { bigint: Math.random() > 0.5 });
}
// Global Tests
diff --git a/types/node/ts3.4/tslint.json b/types/node/ts3.4/tslint.json
index 9061fbd0e3..65e8b18d2a 100644
--- a/types/node/ts3.4/tslint.json
+++ b/types/node/ts3.4/tslint.json
@@ -1,6 +1,10 @@
{
- "extends": "dtslint/dt.json",
- "rules": {
- "no-bad-reference": false
- }
+ "extends": "dtslint/dt.json",
+ "rules": {
+ "ban-types": false,
+ "no-bad-reference": false,
+ "no-empty-interface": false,
+ "no-single-declare-module": false,
+ "unified-signatures": false
+ }
}
diff --git a/types/node/ts3.6/index.d.ts b/types/node/ts3.6/index.d.ts
index 8a427bb210..23b9a61dde 100644
--- a/types/node/ts3.6/index.d.ts
+++ b/types/node/ts3.6/index.d.ts
@@ -5,4 +5,4 @@
///
// tslint:disable-next-line:no-bad-reference
-///
+///
diff --git a/types/node/ts3.6/node-tests.ts b/types/node/ts3.6/node-tests.ts
index 5f1cc57a79..b341061ae0 100644
--- a/types/node/ts3.6/node-tests.ts
+++ b/types/node/ts3.6/node-tests.ts
@@ -1,29 +1,5 @@
// tslint:disable-next-line:no-bad-reference
-import '../ts3.1/node-tests';
-import '../ts3.1/assert';
-import '../ts3.1/buffer';
-import '../ts3.1/child_process';
-import '../ts3.1/cluster';
-import '../ts3.1/crypto';
-import '../ts3.1/dgram';
-import '../ts3.1/ts3.2/fs';
-import '../ts3.1/ts3.2/global';
-import '../ts3.1/http';
-import '../ts3.1/http2';
-import '../ts3.1/net';
-import '../ts3.1/os';
-import '../ts3.1/path';
-import '../ts3.1/perf_hooks';
-import '../ts3.1/process';
-import '../ts3.1/querystring';
-import '../ts3.1/readline';
-import '../ts3.1/repl';
-import '../ts3.1/stream';
-import '../ts3.1/tls';
-import '../ts3.1/tty';
-import '../ts3.1/ts3.2/util';
-import '../ts3.1/worker_threads';
-import '../ts3.1/zlib';
+import '../ts3.4/node-tests';
/////////////////////////////////////////////////////
/// WASI tests : https://nodejs.org/api/wasi.html ///
diff --git a/types/node/util.d.ts b/types/node/util.d.ts
index 84d7ae2c0b..f4d1bda167 100644
--- a/types/node/util.d.ts
+++ b/types/node/util.d.ts
@@ -1,9 +1,196 @@
-// tslint:disable-next-line:no-bad-reference
-///
-
declare module "util" {
+ interface InspectOptions extends NodeJS.InspectOptions { }
+ type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
+ type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
+ interface InspectOptionsStylized extends InspectOptions {
+ stylize(text: string, styleType: Style): string;
+ }
+ function format(format: any, ...param: any[]): string;
+ function formatWithOptions(inspectOptions: InspectOptions, format: string, ...param: any[]): string;
+ /** @deprecated since v0.11.3 - use a third party module instead. */
+ function log(string: string): void;
+ function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
+ function inspect(object: any, options: InspectOptions): string;
+ namespace inspect {
+ let colors: NodeJS.Dict<[number, number]>;
+ let styles: {
+ [K in Style]: string
+ };
+ let defaultOptions: InspectOptions;
+ /**
+ * Allows changing inspect settings from the repl.
+ */
+ let replDefaults: InspectOptions;
+ const custom: unique symbol;
+ }
+ /** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
+ function isArray(object: any): object is any[];
+ /** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
+ function isRegExp(object: any): object is RegExp;
+ /** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
+ function isDate(object: any): object is Date;
+ /** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
+ function isError(object: any): object is Error;
+ function inherits(constructor: any, superConstructor: any): void;
+ function debuglog(key: string): (msg: string, ...param: any[]) => void;
+ /** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
+ function isBoolean(object: any): object is boolean;
+ /** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
+ function isBuffer(object: any): object is Buffer;
+ /** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
+ function isFunction(object: any): boolean;
+ /** @deprecated since v4.0.0 - use `value === null` instead. */
+ function isNull(object: any): object is null;
+ /** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
+ function isNullOrUndefined(object: any): object is null | undefined;
+ /** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
+ function isNumber(object: any): object is number;
+ /** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
+ function isObject(object: any): boolean;
+ /** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
+ function isPrimitive(object: any): boolean;
+ /** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
+ function isString(object: any): object is string;
+ /** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
+ function isSymbol(object: any): object is symbol;
+ /** @deprecated since v4.0.0 - use `value === undefined` instead. */
+ function isUndefined(object: any): object is undefined;
+ function deprecate(fn: T, message: string, code?: string): T;
+ function isDeepStrictEqual(val1: any, val2: any): boolean;
+
+ function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException) => void) => void;
+ function callbackify(fn: () => Promise): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
+ function callbackify(fn: (arg1: T1) => Promise): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
+ function callbackify(fn: (arg1: T1) => Promise