Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add callback function signatures in fs.md #13424

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ changes:
* `path` {string|Buffer|URL}
* `mode` {integer} **Default:** `fs.constants.F_OK`
* `callback` {Function}
* `err` {Error}

Tests a user's permissions for the file or directory specified by `path`.
The `mode` argument is an optional integer that specifies the accessibility
Expand Down Expand Up @@ -600,6 +601,7 @@ changes:
* `mode` {integer} **Default:** `0o666`
* `flag` {string} **Default:** `'a'`
* `callback` {Function}
* `err` {Error}

Asynchronously append data to a file, creating the file if it does not yet exist.
`data` can be a string or a buffer.
Expand Down Expand Up @@ -662,6 +664,7 @@ changes:
* `path` {string|Buffer|URL}
* `mode` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous chmod(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -699,6 +702,7 @@ changes:
* `uid` {integer}
* `gid` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous chown(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -731,6 +735,7 @@ changes:

* `fd` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous close(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -980,6 +985,7 @@ deprecated: v1.0.0

* `path` {string|Buffer|URL}
* `callback` {Function}
* `exists` {Boolean}

Test whether or not the given path exists by checking with the file system.
Then call the `callback` argument with either true or false. Example:
Expand Down Expand Up @@ -1108,6 +1114,7 @@ changes:
* `fd` {integer}
* `mode` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous fchmod(2). No arguments other than a possible exception
are given to the completion callback.
Expand Down Expand Up @@ -1136,6 +1143,7 @@ changes:
* `uid` {integer}
* `gid` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous fchown(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -1163,6 +1171,7 @@ changes:

* `fd` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous fdatasync(2). No arguments other than a possible exception are
given to the completion callback.
Expand All @@ -1188,6 +1197,8 @@ changes:

* `fd` {integer}
* `callback` {Function}
* `err` {Error}
* `stats` {fs.Stats}

Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
`stats` is an [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][],
Expand All @@ -1214,6 +1225,7 @@ changes:

* `fd` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous fsync(2). No arguments other than a possible exception are given
to the completion callback.
Expand All @@ -1240,6 +1252,7 @@ changes:
* `fd` {integer}
* `len` {integer} **Default:** `0`
* `callback` {Function}
* `err` {Error}

Asynchronous ftruncate(2). No arguments other than a possible exception are
given to the completion callback.
Expand Down Expand Up @@ -1313,6 +1326,7 @@ changes:
* `atime` {integer}
* `mtime` {integer}
* `callback` {Function}
* `err` {Error}

Change the file timestamps of a file referenced by the supplied file
descriptor.
Expand Down Expand Up @@ -1349,6 +1363,7 @@ changes:
* `path` {string|Buffer}
* `mode` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous lchmod(2). No arguments other than a possible exception
are given to the completion callback.
Expand Down Expand Up @@ -1379,6 +1394,7 @@ changes:
* `uid` {integer}
* `gid` {integer}
* `callback` {Function}
* `err` {Error}

Asynchronous lchown(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -1412,6 +1428,7 @@ changes:
* `existingPath` {string|Buffer|URL}
* `newPath` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}

Asynchronous link(2). No arguments other than a possible exception are given to
the completion callback.
Expand Down Expand Up @@ -1448,6 +1465,8 @@ changes:

* `path` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}
* `stats` {fs.Stats}

Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
`stats` is a [`fs.Stats`][] object. `lstat()` is identical to `stat()`,
Expand Down Expand Up @@ -1485,6 +1504,7 @@ changes:
* `path` {string|Buffer|URL}
* `mode` {integer} **Default:** `0o777`
* `callback` {Function}
* `err` {Error}

Asynchronous mkdir(2). No arguments other than a possible exception are given
to the completion callback. `mode` defaults to `0o777`.
Expand Down Expand Up @@ -1521,6 +1541,8 @@ changes:
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `folder` {string}

Creates a unique temporary directory.

Expand Down Expand Up @@ -1603,6 +1625,8 @@ changes:
* `flags` {string|number}
* `mode` {integer} **Default:** `0o666`
* `callback` {Function}
* `err` {Error}
* `fd` {integer}

Asynchronous file open. See open(2). `flags` can be:

Expand Down Expand Up @@ -1721,6 +1745,9 @@ changes:
* `length` {integer}
* `position` {integer}
* `callback` {Function}
* `err` {Error}
* `bytesRead` {integer}
* `buffer` {Buffer}

Read data from the file specified by `fd`.

Expand Down Expand Up @@ -1761,6 +1788,8 @@ changes:
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `files` {string[]|Buffer[]}

Asynchronous readdir(3). Reads the contents of a directory.
The callback gets two arguments `(err, files)` where `files` is an array of
Expand Down Expand Up @@ -1819,6 +1848,8 @@ changes:
* `encoding` {string|null} **Default:** `null`
* `flag` {string} **Default:** `'r'`
* `callback` {Function}
* `err` {Error}
* `data` {string|Buffer}

Asynchronously reads the entire contents of a file. Example:

Expand Down Expand Up @@ -1914,6 +1945,8 @@ changes:
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `linkString` {string|Buffer}

Asynchronous readlink(2). The callback gets two arguments `(err,
linkString)`.
Expand Down Expand Up @@ -1989,6 +2022,8 @@ changes:
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `resolvedPath` {string|Buffer}

Asynchronous realpath(3). The `callback` gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths.
Expand Down Expand Up @@ -2057,6 +2092,7 @@ changes:
* `oldPath` {string|Buffer|URL}
* `newPath` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}

Asynchronous rename(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -2093,6 +2129,7 @@ changes:

* `path` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}

Asynchronous rmdir(2). No arguments other than a possible exception are given
to the completion callback.
Expand Down Expand Up @@ -2133,6 +2170,8 @@ changes:

* `path` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}
* `stats` {fs.Stats}

Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
`stats` is an [`fs.Stats`][] object.
Expand Down Expand Up @@ -2176,6 +2215,7 @@ changes:
* `path` {string|Buffer|URL}
* `type` {string} **Default:** `'file'`
* `callback` {Function}
* `err` {Error}

Asynchronous symlink(2). No arguments other than a possible exception are given
to the completion callback. The `type` argument can be set to `'dir'`,
Expand Down Expand Up @@ -2222,6 +2262,7 @@ changes:
* `path` {string|Buffer}
* `len` {integer} **Default:** `0`
* `callback` {Function}
* `err` {Error}

Asynchronous truncate(2). No arguments other than a possible exception are
given to the completion callback. A file descriptor can also be passed as the
Expand Down Expand Up @@ -2254,6 +2295,7 @@ changes:

* `path` {string|Buffer|URL}
* `callback` {Function}
* `err` {Error}

Asynchronous unlink(2). No arguments other than a possible exception are given
to the completion callback.
Expand All @@ -2279,6 +2321,8 @@ added: v0.1.31

* `filename` {string|Buffer}
* `listener` {Function|undefined} **Default:** `undefined`
* `eventType` {string}
* `filename` {string|Buffer}

Stop watching for changes on `filename`. If `listener` is specified, only that
particular listener is removed. Otherwise, *all* listeners are removed,
Expand Down Expand Up @@ -2313,6 +2357,7 @@ changes:
* `atime` {integer}
* `mtime` {integer}
* `callback` {Function}
* `err` {Error}

Change file timestamps of the file referenced by the supplied path.

Expand Down Expand Up @@ -2369,6 +2414,8 @@ changes:
* `encoding` {string} Specifies the character encoding to be used for the
filename passed to the listener. **Default:** `'utf8'`
* `listener` {Function|undefined} **Default:** `undefined`
* `eventType` {string}
* `filename` {string|Buffer}

Watch for changes on `filename`, where `filename` is either a file or a
directory. The returned object is a [`fs.FSWatcher`][].
Expand Down Expand Up @@ -2471,6 +2518,8 @@ changes:
* `persistent` {boolean} **Default:** `true`
* `interval` {integer} **Default:** `5007`
* `listener` {Function}
* `current` {fs.Stats}
* `previous` {fs.Stats}

Watch for changes on `filename`. The callback `listener` will be called each
time the file is accessed.
Expand Down Expand Up @@ -2530,6 +2579,9 @@ changes:
* `length` {integer}
* `position` {integer}
* `callback` {Function}
* `err` {Error}
* `bytesWritten` {integer}
* `buffer` {Buffer|Uint8Array}

Write `buffer` to the file specified by `fd`.

Expand Down Expand Up @@ -2572,6 +2624,9 @@ changes:
* `position` {integer}
* `encoding` {string}
* `callback` {Function}
* `err` {Error}
* `written` {integer}
* `string` {string}

Write `string` to the file specified by `fd`. If `string` is not a string, then
the value will be coerced to one.
Expand Down Expand Up @@ -2621,6 +2676,7 @@ changes:
* `mode` {integer} **Default:** `0o666`
* `flag` {string} **Default:** `'w'`
* `callback` {Function}
* `err` {Error}

Asynchronously writes data to a file, replacing the file if it already exists.
`data` can be a string or a buffer.
Expand Down