CoolFace
Apppublic

Pinsave/counterstrike

sourceHugging Faceupdated 3mo agoView on Hugging Face
1likes
fs.d.ts4459 linesDownload Raw Back to node
1/**2 * The `node:fs` module enables interacting with the file system in a3 * way modeled on standard POSIX functions.4 *5 * To use the promise-based APIs:6 *7 * ```js8 * import * as fs from 'node:fs/promises';9 * ```10 *11 * To use the callback and sync APIs:12 *13 * ```js14 * import * as fs from 'node:fs';15 * ```16 *17 * All file system operations have synchronous, callback, and promise-based18 * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).19 * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)20 */21declare module "fs" {22    import * as stream from "node:stream";23    import { Abortable, EventEmitter } from "node:events";24    import { URL } from "node:url";25    import * as promises from "node:fs/promises";26    export { promises };27    /**28     * Valid types for path values in "fs".29     */30    export type PathLike = string | Buffer | URL;31    export type PathOrFileDescriptor = PathLike | number;32    export type TimeLike = string | number | Date;33    export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;34    export type BufferEncodingOption =35        | "buffer"36        | {37            encoding: "buffer";38        };39    export interface ObjectEncodingOptions {40        encoding?: BufferEncoding | null | undefined;41    }42    export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;43    export type OpenMode = number | string;44    export type Mode = number | string;45    export interface StatsBase<T> {46        isFile(): boolean;47        isDirectory(): boolean;48        isBlockDevice(): boolean;49        isCharacterDevice(): boolean;50        isSymbolicLink(): boolean;51        isFIFO(): boolean;52        isSocket(): boolean;53        dev: T;54        ino: T;55        mode: T;56        nlink: T;57        uid: T;58        gid: T;59        rdev: T;60        size: T;61        blksize: T;62        blocks: T;63        atimeMs: T;64        mtimeMs: T;65        ctimeMs: T;66        birthtimeMs: T;67        atime: Date;68        mtime: Date;69        ctime: Date;70        birthtime: Date;71    }72    export interface Stats extends StatsBase<number> {}73    /**74     * A `fs.Stats` object provides information about a file.75     *76     * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and77     * their synchronous counterparts are of this type.78     * If `bigint` in the `options` passed to those methods is true, the numeric values79     * will be `bigint` instead of `number`, and the object will contain additional80     * nanosecond-precision properties suffixed with `Ns`. `Stat` objects are not to be created directly using the `new` keyword.81     *82     * ```console83     * Stats {84     *   dev: 2114,85     *   ino: 48064969,86     *   mode: 33188,87     *   nlink: 1,88     *   uid: 85,89     *   gid: 100,90     *   rdev: 0,91     *   size: 527,92     *   blksize: 4096,93     *   blocks: 8,94     *   atimeMs: 1318289051000.1,95     *   mtimeMs: 1318289051000.1,96     *   ctimeMs: 1318289051000.1,97     *   birthtimeMs: 1318289051000.1,98     *   atime: Mon, 10 Oct 2011 23:24:11 GMT,99     *   mtime: Mon, 10 Oct 2011 23:24:11 GMT,100     *   ctime: Mon, 10 Oct 2011 23:24:11 GMT,101     *   birthtime: Mon, 10 Oct 2011 23:24:11 GMT }102     * ```103     *104     * `bigint` version:105     *106     * ```console107     * BigIntStats {108     *   dev: 2114n,109     *   ino: 48064969n,110     *   mode: 33188n,111     *   nlink: 1n,112     *   uid: 85n,113     *   gid: 100n,114     *   rdev: 0n,115     *   size: 527n,116     *   blksize: 4096n,117     *   blocks: 8n,118     *   atimeMs: 1318289051000n,119     *   mtimeMs: 1318289051000n,120     *   ctimeMs: 1318289051000n,121     *   birthtimeMs: 1318289051000n,122     *   atimeNs: 1318289051000000000n,123     *   mtimeNs: 1318289051000000000n,124     *   ctimeNs: 1318289051000000000n,125     *   birthtimeNs: 1318289051000000000n,126     *   atime: Mon, 10 Oct 2011 23:24:11 GMT,127     *   mtime: Mon, 10 Oct 2011 23:24:11 GMT,128     *   ctime: Mon, 10 Oct 2011 23:24:11 GMT,129     *   birthtime: Mon, 10 Oct 2011 23:24:11 GMT }130     * ```131     * @since v0.1.21132     */133    export class Stats {134        private constructor();135    }136    export interface StatsFsBase<T> {137        /** Type of file system. */138        type: T;139        /**  Optimal transfer block size. */140        bsize: T;141        /**  Total data blocks in file system. */142        blocks: T;143        /** Free blocks in file system. */144        bfree: T;145        /** Available blocks for unprivileged users */146        bavail: T;147        /** Total file nodes in file system. */148        files: T;149        /** Free file nodes in file system. */150        ffree: T;151    }152    export interface StatsFs extends StatsFsBase<number> {}153    /**154     * Provides information about a mounted file system.155     *156     * Objects returned from {@link statfs} and its synchronous counterpart are of157     * this type. If `bigint` in the `options` passed to those methods is `true`, the158     * numeric values will be `bigint` instead of `number`.159     *160     * ```console161     * StatFs {162     *   type: 1397114950,163     *   bsize: 4096,164     *   blocks: 121938943,165     *   bfree: 61058895,166     *   bavail: 61058895,167     *   files: 999,168     *   ffree: 1000000169     * }170     * ```171     *172     * `bigint` version:173     *174     * ```console175     * StatFs {176     *   type: 1397114950n,177     *   bsize: 4096n,178     *   blocks: 121938943n,179     *   bfree: 61058895n,180     *   bavail: 61058895n,181     *   files: 999n,182     *   ffree: 1000000n183     * }184     * ```185     * @since v19.6.0, v18.15.0186     */187    export class StatsFs {}188    export interface BigIntStatsFs extends StatsFsBase<bigint> {}189    export interface StatFsOptions {190        bigint?: boolean | undefined;191    }192    /**193     * A representation of a directory entry, which can be a file or a subdirectory194     * within the directory, as returned by reading from an `fs.Dir`. The195     * directory entry is a combination of the file name and file type pairs.196     *197     * Additionally, when {@link readdir} or {@link readdirSync} is called with198     * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.199     * @since v10.10.0200     */201    export class Dirent<Name extends string | Buffer = string> {202        /**203         * Returns `true` if the `fs.Dirent` object describes a regular file.204         * @since v10.10.0205         */206        isFile(): boolean;207        /**208         * Returns `true` if the `fs.Dirent` object describes a file system209         * directory.210         * @since v10.10.0211         */212        isDirectory(): boolean;213        /**214         * Returns `true` if the `fs.Dirent` object describes a block device.215         * @since v10.10.0216         */217        isBlockDevice(): boolean;218        /**219         * Returns `true` if the `fs.Dirent` object describes a character device.220         * @since v10.10.0221         */222        isCharacterDevice(): boolean;223        /**224         * Returns `true` if the `fs.Dirent` object describes a symbolic link.225         * @since v10.10.0226         */227        isSymbolicLink(): boolean;228        /**229         * Returns `true` if the `fs.Dirent` object describes a first-in-first-out230         * (FIFO) pipe.231         * @since v10.10.0232         */233        isFIFO(): boolean;234        /**235         * Returns `true` if the `fs.Dirent` object describes a socket.236         * @since v10.10.0237         */238        isSocket(): boolean;239        /**240         * The file name that this `fs.Dirent` object refers to. The type of this241         * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.242         * @since v10.10.0243         */244        name: Name;245        /**246         * The path to the parent directory of the file this `fs.Dirent` object refers to.247         * @since v20.12.0, v18.20.0248         */249        parentPath: string;250    }251    /**252     * A class representing a directory stream.253     *254     * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`.255     *256     * ```js257     * import { opendir } from 'node:fs/promises';258     *259     * try {260     *   const dir = await opendir('./');261     *   for await (const dirent of dir)262     *     console.log(dirent.name);263     * } catch (err) {264     *   console.error(err);265     * }266     * ```267     *268     * When using the async iterator, the `fs.Dir` object will be automatically269     * closed after the iterator exits.270     * @since v12.12.0271     */272    export class Dir implements AsyncIterable<Dirent> {273        /**274         * The read-only path of this directory as was provided to {@link opendir},{@link opendirSync}, or `fsPromises.opendir()`.275         * @since v12.12.0276         */277        readonly path: string;278        /**279         * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.280         */281        [Symbol.asyncIterator](): NodeJS.AsyncIterator<Dirent>;282        /**283         * Asynchronously close the directory's underlying resource handle.284         * Subsequent reads will result in errors.285         *286         * A promise is returned that will be fulfilled after the resource has been287         * closed.288         * @since v12.12.0289         */290        close(): Promise<void>;291        close(cb: NoParamCallback): void;292        /**293         * Synchronously close the directory's underlying resource handle.294         * Subsequent reads will result in errors.295         * @since v12.12.0296         */297        closeSync(): void;298        /**299         * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.300         *301         * A promise is returned that will be fulfilled with an `fs.Dirent`, or `null` if there are no more directory entries to read.302         *303         * Directory entries returned by this function are in no particular order as304         * provided by the operating system's underlying directory mechanisms.305         * Entries added or removed while iterating over the directory might not be306         * included in the iteration results.307         * @since v12.12.0308         * @return containing {fs.Dirent|null}309         */310        read(): Promise<Dirent | null>;311        read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;312        /**313         * Synchronously read the next directory entry as an `fs.Dirent`. See the314         * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.315         *316         * If there are no more directory entries to read, `null` will be returned.317         *318         * Directory entries returned by this function are in no particular order as319         * provided by the operating system's underlying directory mechanisms.320         * Entries added or removed while iterating over the directory might not be321         * included in the iteration results.322         * @since v12.12.0323         */324        readSync(): Dirent | null;325        /**326         * An alias for `dir.close()`.327         * @since v24.1.0328         * @experimental329         */330        [Symbol.dispose](): void;331        /**332         * An alias for `dir.closeSync()`.333         * @since v24.1.0334         * @experimental335         */336        [Symbol.asyncDispose](): void;337    }338    /**339     * Class: fs.StatWatcher340     * @since v14.3.0, v12.20.0341     * Extends `EventEmitter`342     * A successful call to {@link watchFile} method will return a new fs.StatWatcher object.343     */344    export interface StatWatcher extends EventEmitter {345        /**346         * When called, requests that the Node.js event loop _not_ exit so long as the `fs.StatWatcher` is active. Calling `watcher.ref()` multiple times will have347         * no effect.348         *349         * By default, all `fs.StatWatcher` objects are "ref'ed", making it normally350         * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been351         * called previously.352         * @since v14.3.0, v12.20.0353         */354        ref(): this;355        /**356         * When called, the active `fs.StatWatcher` object will not require the Node.js357         * event loop to remain active. If there is no other activity keeping the358         * event loop running, the process may exit before the `fs.StatWatcher` object's359         * callback is invoked. Calling `watcher.unref()` multiple times will have360         * no effect.361         * @since v14.3.0, v12.20.0362         */363        unref(): this;364    }365    export interface FSWatcher extends EventEmitter {366        /**367         * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable.368         * @since v0.5.8369         */370        close(): void;371        /**372         * When called, requests that the Node.js event loop _not_ exit so long as the `fs.FSWatcher` is active. Calling `watcher.ref()` multiple times will have373         * no effect.374         *375         * By default, all `fs.FSWatcher` objects are "ref'ed", making it normally376         * unnecessary to call `watcher.ref()` unless `watcher.unref()` had been377         * called previously.378         * @since v14.3.0, v12.20.0379         */380        ref(): this;381        /**382         * When called, the active `fs.FSWatcher` object will not require the Node.js383         * event loop to remain active. If there is no other activity keeping the384         * event loop running, the process may exit before the `fs.FSWatcher` object's385         * callback is invoked. Calling `watcher.unref()` multiple times will have386         * no effect.387         * @since v14.3.0, v12.20.0388         */389        unref(): this;390        /**391         * events.EventEmitter392         *   1. change393         *   2. close394         *   3. error395         */396        addListener(event: string, listener: (...args: any[]) => void): this;397        addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;398        addListener(event: "close", listener: () => void): this;399        addListener(event: "error", listener: (error: Error) => void): this;400        on(event: string, listener: (...args: any[]) => void): this;401        on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;402        on(event: "close", listener: () => void): this;403        on(event: "error", listener: (error: Error) => void): this;404        once(event: string, listener: (...args: any[]) => void): this;405        once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;406        once(event: "close", listener: () => void): this;407        once(event: "error", listener: (error: Error) => void): this;408        prependListener(event: string, listener: (...args: any[]) => void): this;409        prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;410        prependListener(event: "close", listener: () => void): this;411        prependListener(event: "error", listener: (error: Error) => void): this;412        prependOnceListener(event: string, listener: (...args: any[]) => void): this;413        prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;414        prependOnceListener(event: "close", listener: () => void): this;415        prependOnceListener(event: "error", listener: (error: Error) => void): this;416    }417    /**418     * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.419     * @since v0.1.93420     */421    export class ReadStream extends stream.Readable {422        close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;423        /**424         * The number of bytes that have been read so far.425         * @since v6.4.0426         */427        bytesRead: number;428        /**429         * The path to the file the stream is reading from as specified in the first430         * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a431         * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.432         * @since v0.1.93433         */434        path: string | Buffer;435        /**436         * This property is `true` if the underlying file has not been opened yet,437         * i.e. before the `'ready'` event is emitted.438         * @since v11.2.0, v10.16.0439         */440        pending: boolean;441        /**442         * events.EventEmitter443         *   1. open444         *   2. close445         *   3. ready446         */447        addListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;448        on<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;449        once<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;450        prependListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;451        prependOnceListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;452    }453 454    /**455     * The Keys are events of the ReadStream and the values are the functions that are called when the event is emitted.456     */457    type ReadStreamEvents = {458        close: () => void;459        data: (chunk: Buffer | string) => void;460        end: () => void;461        error: (err: Error) => void;462        open: (fd: number) => void;463        pause: () => void;464        readable: () => void;465        ready: () => void;466        resume: () => void;467    } & CustomEvents;468 469    /**470     * string & {} allows to allow any kind of strings for the event471     * but still allows to have auto completion for the normal events.472     */473    type CustomEvents = { [Key in string & {} | symbol]: (...args: any[]) => void };474 475    /**476     * The Keys are events of the WriteStream and the values are the functions that are called when the event is emitted.477     */478    type WriteStreamEvents = {479        close: () => void;480        drain: () => void;481        error: (err: Error) => void;482        finish: () => void;483        open: (fd: number) => void;484        pipe: (src: stream.Readable) => void;485        ready: () => void;486        unpipe: (src: stream.Readable) => void;487    } & CustomEvents;488    /**489     * * Extends `stream.Writable`490     *491     * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.492     * @since v0.1.93493     */494    export class WriteStream extends stream.Writable {495        /**496         * Closes `writeStream`. Optionally accepts a497         * callback that will be executed once the `writeStream`is closed.498         * @since v0.9.4499         */500        close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;501        /**502         * The number of bytes written so far. Does not include data that is still queued503         * for writing.504         * @since v0.4.7505         */506        bytesWritten: number;507        /**508         * The path to the file the stream is writing to as specified in the first509         * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a510         * `Buffer`.511         * @since v0.1.93512         */513        path: string | Buffer;514        /**515         * This property is `true` if the underlying file has not been opened yet,516         * i.e. before the `'ready'` event is emitted.517         * @since v11.2.0518         */519        pending: boolean;520        /**521         * events.EventEmitter522         *   1. open523         *   2. close524         *   3. ready525         */526        addListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;527        on<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;528        once<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;529        prependListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;530        prependOnceListener<K extends keyof WriteStreamEvents>(event: K, listener: WriteStreamEvents[K]): this;531    }532    /**533     * Asynchronously rename file at `oldPath` to the pathname provided534     * as `newPath`. In the case that `newPath` already exists, it will535     * be overwritten. If there is a directory at `newPath`, an error will536     * be raised instead. No arguments other than a possible exception are537     * given to the completion callback.538     *539     * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).540     *541     * ```js542     * import { rename } from 'node:fs';543     *544     * rename('oldFile.txt', 'newFile.txt', (err) => {545     *   if (err) throw err;546     *   console.log('Rename complete!');547     * });548     * ```549     * @since v0.0.2550     */551    export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;552    export namespace rename {553        /**554         * Asynchronous rename(2) - Change the name or location of a file or directory.555         * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.556         * URL support is _experimental_.557         * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.558         * URL support is _experimental_.559         */560        function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;561    }562    /**563     * Renames the file from `oldPath` to `newPath`. Returns `undefined`.564     *565     * See the POSIX [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html) documentation for more details.566     * @since v0.1.21567     */568    export function renameSync(oldPath: PathLike, newPath: PathLike): void;569    /**570     * Truncates the file. No arguments other than a possible exception are571     * given to the completion callback. A file descriptor can also be passed as the572     * first argument. In this case, `fs.ftruncate()` is called.573     *574     * ```js575     * import { truncate } from 'node:fs';576     * // Assuming that 'path/file.txt' is a regular file.577     * truncate('path/file.txt', (err) => {578     *   if (err) throw err;579     *   console.log('path/file.txt was truncated');580     * });581     * ```582     *583     * Passing a file descriptor is deprecated and may result in an error being thrown584     * in the future.585     *586     * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.587     * @since v0.8.6588     * @param [len=0]589     */590    export function truncate(path: PathLike, len: number | undefined, callback: NoParamCallback): void;591    /**592     * Asynchronous truncate(2) - Truncate a file to a specified length.593     * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.594     */595    export function truncate(path: PathLike, callback: NoParamCallback): void;596    export namespace truncate {597        /**598         * Asynchronous truncate(2) - Truncate a file to a specified length.599         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.600         * @param len If not specified, defaults to `0`.601         */602        function __promisify__(path: PathLike, len?: number): Promise<void>;603    }604    /**605     * Truncates the file. Returns `undefined`. A file descriptor can also be606     * passed as the first argument. In this case, `fs.ftruncateSync()` is called.607     *608     * Passing a file descriptor is deprecated and may result in an error being thrown609     * in the future.610     * @since v0.8.6611     * @param [len=0]612     */613    export function truncateSync(path: PathLike, len?: number): void;614    /**615     * Truncates the file descriptor. No arguments other than a possible exception are616     * given to the completion callback.617     *618     * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.619     *620     * If the file referred to by the file descriptor was larger than `len` bytes, only621     * the first `len` bytes will be retained in the file.622     *623     * For example, the following program retains only the first four bytes of the624     * file:625     *626     * ```js627     * import { open, close, ftruncate } from 'node:fs';628     *629     * function closeFd(fd) {630     *   close(fd, (err) => {631     *     if (err) throw err;632     *   });633     * }634     *635     * open('temp.txt', 'r+', (err, fd) => {636     *   if (err) throw err;637     *638     *   try {639     *     ftruncate(fd, 4, (err) => {640     *       closeFd(fd);641     *       if (err) throw err;642     *     });643     *   } catch (err) {644     *     closeFd(fd);645     *     if (err) throw err;646     *   }647     * });648     * ```649     *650     * If the file previously was shorter than `len` bytes, it is extended, and the651     * extended part is filled with null bytes (`'\0'`):652     *653     * If `len` is negative then `0` will be used.654     * @since v0.8.6655     * @param [len=0]656     */657    export function ftruncate(fd: number, len: number | undefined, callback: NoParamCallback): void;658    /**659     * Asynchronous ftruncate(2) - Truncate a file to a specified length.660     * @param fd A file descriptor.661     */662    export function ftruncate(fd: number, callback: NoParamCallback): void;663    export namespace ftruncate {664        /**665         * Asynchronous ftruncate(2) - Truncate a file to a specified length.666         * @param fd A file descriptor.667         * @param len If not specified, defaults to `0`.668         */669        function __promisify__(fd: number, len?: number): Promise<void>;670    }671    /**672     * Truncates the file descriptor. Returns `undefined`.673     *674     * For detailed information, see the documentation of the asynchronous version of675     * this API: {@link ftruncate}.676     * @since v0.8.6677     * @param [len=0]678     */679    export function ftruncateSync(fd: number, len?: number): void;680    /**681     * Asynchronously changes owner and group of a file. No arguments other than a682     * possible exception are given to the completion callback.683     *684     * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.685     * @since v0.1.97686     */687    export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;688    export namespace chown {689        /**690         * Asynchronous chown(2) - Change ownership of a file.691         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.692         */693        function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;694    }695    /**696     * Synchronously changes owner and group of a file. Returns `undefined`.697     * This is the synchronous version of {@link chown}.698     *699     * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.700     * @since v0.1.97701     */702    export function chownSync(path: PathLike, uid: number, gid: number): void;703    /**704     * Sets the owner of the file. No arguments other than a possible exception are705     * given to the completion callback.706     *707     * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.708     * @since v0.4.7709     */710    export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;711    export namespace fchown {712        /**713         * Asynchronous fchown(2) - Change ownership of a file.714         * @param fd A file descriptor.715         */716        function __promisify__(fd: number, uid: number, gid: number): Promise<void>;717    }718    /**719     * Sets the owner of the file. Returns `undefined`.720     *721     * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.722     * @since v0.4.7723     * @param uid The file's new owner's user id.724     * @param gid The file's new group's group id.725     */726    export function fchownSync(fd: number, uid: number, gid: number): void;727    /**728     * Set the owner of the symbolic link. No arguments other than a possible729     * exception are given to the completion callback.730     *731     * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.732     */733    export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;734    export namespace lchown {735        /**736         * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.737         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.738         */739        function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;740    }741    /**742     * Set the owner for the path. Returns `undefined`.743     *744     * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more details.745     * @param uid The file's new owner's user id.746     * @param gid The file's new group's group id.747     */748    export function lchownSync(path: PathLike, uid: number, gid: number): void;749    /**750     * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic751     * link, then the link is not dereferenced: instead, the timestamps of the752     * symbolic link itself are changed.753     *754     * No arguments other than a possible exception are given to the completion755     * callback.756     * @since v14.5.0, v12.19.0757     */758    export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;759    export namespace lutimes {760        /**761         * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`,762         * with the difference that if the path refers to a symbolic link, then the link is not763         * dereferenced: instead, the timestamps of the symbolic link itself are changed.764         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.765         * @param atime The last access time. If a string is provided, it will be coerced to number.766         * @param mtime The last modified time. If a string is provided, it will be coerced to number.767         */768        function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;769    }770    /**771     * Change the file system timestamps of the symbolic link referenced by `path`.772     * Returns `undefined`, or throws an exception when parameters are incorrect or773     * the operation fails. This is the synchronous version of {@link lutimes}.774     * @since v14.5.0, v12.19.0775     */776    export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;777    /**778     * Asynchronously changes the permissions of a file. No arguments other than a779     * possible exception are given to the completion callback.780     *781     * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.782     *783     * ```js784     * import { chmod } from 'node:fs';785     *786     * chmod('my_file.txt', 0o775, (err) => {787     *   if (err) throw err;788     *   console.log('The permissions for file "my_file.txt" have been changed!');789     * });790     * ```791     * @since v0.1.30792     */793    export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;794    export namespace chmod {795        /**796         * Asynchronous chmod(2) - Change permissions of a file.797         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.798         * @param mode A file mode. If a string is passed, it is parsed as an octal integer.799         */800        function __promisify__(path: PathLike, mode: Mode): Promise<void>;801    }802    /**803     * For detailed information, see the documentation of the asynchronous version of804     * this API: {@link chmod}.805     *806     * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.807     * @since v0.6.7808     */809    export function chmodSync(path: PathLike, mode: Mode): void;810    /**811     * Sets the permissions on the file. No arguments other than a possible exception812     * are given to the completion callback.813     *814     * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.815     * @since v0.4.7816     */817    export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;818    export namespace fchmod {819        /**820         * Asynchronous fchmod(2) - Change permissions of a file.821         * @param fd A file descriptor.822         * @param mode A file mode. If a string is passed, it is parsed as an octal integer.823         */824        function __promisify__(fd: number, mode: Mode): Promise<void>;825    }826    /**827     * Sets the permissions on the file. Returns `undefined`.828     *829     * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.830     * @since v0.4.7831     */832    export function fchmodSync(fd: number, mode: Mode): void;833    /**834     * Changes the permissions on a symbolic link. No arguments other than a possible835     * exception are given to the completion callback.836     *837     * This method is only implemented on macOS.838     *839     * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.840     * @deprecated Since v0.4.7841     */842    export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;843    /** @deprecated */844    export namespace lchmod {845        /**846         * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.847         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.848         * @param mode A file mode. If a string is passed, it is parsed as an octal integer.849         */850        function __promisify__(path: PathLike, mode: Mode): Promise<void>;851    }852    /**853     * Changes the permissions on a symbolic link. Returns `undefined`.854     *855     * This method is only implemented on macOS.856     *857     * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.858     * @deprecated Since v0.4.7859     */860    export function lchmodSync(path: PathLike, mode: Mode): void;861    /**862     * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.863     *864     * In case of an error, the `err.code` will be one of `Common System Errors`.865     *866     * {@link stat} follows symbolic links. Use {@link lstat} to look at the867     * links themselves.868     *869     * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.870     * Instead, user code should open/read/write the file directly and handle the871     * error raised if the file is not available.872     *873     * To check if a file exists without manipulating it afterwards, {@link access} is recommended.874     *875     * For example, given the following directory structure:876     *877     * ```text878     * - txtDir879     * -- file.txt880     * - app.js881     * ```882     *883     * The next program will check for the stats of the given paths:884     *885     * ```js886     * import { stat } from 'node:fs';887     *888     * const pathsToCheck = ['./txtDir', './txtDir/file.txt'];889     *890     * for (let i = 0; i < pathsToCheck.length; i++) {891     *   stat(pathsToCheck[i], (err, stats) => {892     *     console.log(stats.isDirectory());893     *     console.log(stats);894     *   });895     * }896     * ```897     *898     * The resulting output will resemble:899     *900     * ```console901     * true902     * Stats {903     *   dev: 16777220,904     *   mode: 16877,905     *   nlink: 3,906     *   uid: 501,907     *   gid: 20,908     *   rdev: 0,909     *   blksize: 4096,910     *   ino: 14214262,911     *   size: 96,912     *   blocks: 0,913     *   atimeMs: 1561174653071.963,914     *   mtimeMs: 1561174614583.3518,915     *   ctimeMs: 1561174626623.5366,916     *   birthtimeMs: 1561174126937.2893,917     *   atime: 2019-06-22T03:37:33.072Z,918     *   mtime: 2019-06-22T03:36:54.583Z,919     *   ctime: 2019-06-22T03:37:06.624Z,920     *   birthtime: 2019-06-22T03:28:46.937Z921     * }922     * false923     * Stats {924     *   dev: 16777220,925     *   mode: 33188,926     *   nlink: 1,927     *   uid: 501,928     *   gid: 20,929     *   rdev: 0,930     *   blksize: 4096,931     *   ino: 14214074,932     *   size: 8,933     *   blocks: 8,934     *   atimeMs: 1561174616618.8555,935     *   mtimeMs: 1561174614584,936     *   ctimeMs: 1561174614583.8145,937     *   birthtimeMs: 1561174007710.7478,938     *   atime: 2019-06-22T03:36:56.619Z,939     *   mtime: 2019-06-22T03:36:54.584Z,940     *   ctime: 2019-06-22T03:36:54.584Z,941     *   birthtime: 2019-06-22T03:26:47.711Z942     * }943     * ```944     * @since v0.0.2945     */946    export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;947    export function stat(948        path: PathLike,949        options:950            | (StatOptions & {951                bigint?: false | undefined;952            })953            | undefined,954        callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,955    ): void;956    export function stat(957        path: PathLike,958        options: StatOptions & {959            bigint: true;960        },961        callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,962    ): void;963    export function stat(964        path: PathLike,965        options: StatOptions | undefined,966        callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,967    ): void;968    export namespace stat {969        /**970         * Asynchronous stat(2) - Get file status.971         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.972         */973        function __promisify__(974            path: PathLike,975            options?: StatOptions & {976                bigint?: false | undefined;977            },978        ): Promise<Stats>;979        function __promisify__(980            path: PathLike,981            options: StatOptions & {982                bigint: true;983            },984        ): Promise<BigIntStats>;985        function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;986    }987    export interface StatSyncFn extends Function {988        (path: PathLike, options?: undefined): Stats;989        (990            path: PathLike,991            options?: StatSyncOptions & {992                bigint?: false | undefined;993                throwIfNoEntry: false;994            },995        ): Stats | undefined;996        (997            path: PathLike,998            options: StatSyncOptions & {999                bigint: true;1000                throwIfNoEntry: false;1001            },1002        ): BigIntStats | undefined;1003        (1004            path: PathLike,1005            options?: StatSyncOptions & {1006                bigint?: false | undefined;1007            },1008        ): Stats;1009        (1010            path: PathLike,1011            options: StatSyncOptions & {1012                bigint: true;1013            },1014        ): BigIntStats;1015        (1016            path: PathLike,1017            options: StatSyncOptions & {1018                bigint: boolean;1019                throwIfNoEntry?: false | undefined;1020            },1021        ): Stats | BigIntStats;1022        (path: PathLike, options?: StatSyncOptions): Stats | BigIntStats | undefined;1023    }1024    /**1025     * Synchronous stat(2) - Get file status.1026     * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.1027     */1028    export const statSync: StatSyncFn;1029    /**1030     * Invokes the callback with the `fs.Stats` for the file descriptor.1031     *1032     * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.1033     * @since v0.1.951034     */1035    export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;1036    export function fstat(1037        fd: number,1038        options:1039            | (StatOptions & {1040                bigint?: false | undefined;1041            })1042            | undefined,1043        callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,1044    ): void;1045    export function fstat(1046        fd: number,1047        options: StatOptions & {1048            bigint: true;1049        },1050        callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,1051    ): void;1052    export function fstat(1053        fd: number,1054        options: StatOptions | undefined,1055        callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,1056    ): void;1057    export namespace fstat {1058        /**1059         * Asynchronous fstat(2) - Get file status.1060         * @param fd A file descriptor.1061         */1062        function __promisify__(1063            fd: number,1064            options?: StatOptions & {1065                bigint?: false | undefined;1066            },1067        ): Promise<Stats>;1068        function __promisify__(1069            fd: number,1070            options: StatOptions & {1071                bigint: true;1072            },1073        ): Promise<BigIntStats>;1074        function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;1075    }1076    /**1077     * Retrieves the `fs.Stats` for the file descriptor.1078     *1079     * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.1080     * @since v0.1.951081     */1082    export function fstatSync(1083        fd: number,1084        options?: StatOptions & {1085            bigint?: false | undefined;1086        },1087    ): Stats;1088    export function fstatSync(1089        fd: number,1090        options: StatOptions & {1091            bigint: true;1092        },1093    ): BigIntStats;1094    export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;1095    /**1096     * Retrieves the `fs.Stats` for the symbolic link referred to by the path.1097     * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic1098     * link, then the link itself is stat-ed, not the file that it refers to.1099     *1100     * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.1101     * @since v0.1.301102     */1103    export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;1104    export function lstat(1105        path: PathLike,1106        options:1107            | (StatOptions & {1108                bigint?: false | undefined;1109            })1110            | undefined,1111        callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,1112    ): void;1113    export function lstat(1114        path: PathLike,1115        options: StatOptions & {1116            bigint: true;1117        },1118        callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,1119    ): void;1120    export function lstat(1121        path: PathLike,1122        options: StatOptions | undefined,1123        callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,1124    ): void;1125    export namespace lstat {1126        /**1127         * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.1128         * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.1129         */1130        function __promisify__(1131            path: PathLike,1132            options?: StatOptions & {1133                bigint?: false | undefined;1134            },1135        ): Promise<Stats>;1136        function __promisify__(1137            path: PathLike,1138            options: StatOptions & {1139                bigint: true;1140            },1141        ): Promise<BigIntStats>;1142        function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;1143    }1144    /**1145     * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which1146     * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.1147     *1148     * In case of an error, the `err.code` will be one of `Common System Errors`.1149     * @since v19.6.0, v18.15.01150     * @param path A path to an existing file or directory on the file system to be queried.1151     */1152    export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void;1153    export function statfs(1154        path: PathLike,1155        options:1156            | (StatFsOptions & {1157                bigint?: false | undefined;1158            })1159            | undefined,1160        callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void,1161    ): void;1162    export function statfs(1163        path: PathLike,1164        options: StatFsOptions & {1165            bigint: true;1166        },1167        callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void,1168    ): void;1169    export function statfs(1170        path: PathLike,1171        options: StatFsOptions | undefined,1172        callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void,1173    ): void;1174    export namespace statfs {1175        /**1176         * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an <fs.StatFs> object.1177         * @param path A path to an existing file or directory on the file system to be queried.1178         */1179        function __promisify__(1180            path: PathLike,1181            options?: StatFsOptions & {1182                bigint?: false | undefined;1183            },1184        ): Promise<StatsFs>;1185        function __promisify__(1186            path: PathLike,1187            options: StatFsOptions & {1188                bigint: true;1189            },1190        ): Promise<BigIntStatsFs>;1191        function __promisify__(path: PathLike, options?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;1192    }1193    /**1194     * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which1195     * contains `path`.1196     *1197     * In case of an error, the `err.code` will be one of `Common System Errors`.1198     * @since v19.6.0, v18.15.01199     * @param path A path to an existing file or directory on the file system to be queried.1200     */

Showing the first 1,200 of 4459 lines. Download the file for the rest.