doc: add callback function signatures in fs.md
PR-URL: https://github.com/nodejs/node/pull/13424 Refs: https://github.com/nodejs/node/issues/11135 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
9af9bcbaf5
commit
a636b72645
@ -448,6 +448,7 @@ changes:
|
|||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `mode` {integer} **Default:** `fs.constants.F_OK`
|
* `mode` {integer} **Default:** `fs.constants.F_OK`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Tests a user's permissions for the file or directory specified by `path`.
|
Tests a user's permissions for the file or directory specified by `path`.
|
||||||
The `mode` argument is an optional integer that specifies the accessibility
|
The `mode` argument is an optional integer that specifies the accessibility
|
||||||
@ -600,6 +601,7 @@ changes:
|
|||||||
* `mode` {integer} **Default:** `0o666`
|
* `mode` {integer} **Default:** `0o666`
|
||||||
* `flag` {string} **Default:** `'a'`
|
* `flag` {string} **Default:** `'a'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronously append data to a file, creating the file if it does not yet exist.
|
Asynchronously append data to a file, creating the file if it does not yet exist.
|
||||||
`data` can be a string or a buffer.
|
`data` can be a string or a buffer.
|
||||||
@ -662,6 +664,7 @@ changes:
|
|||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `mode` {integer}
|
* `mode` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous chmod(2). No arguments other than a possible exception are given
|
Asynchronous chmod(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -699,6 +702,7 @@ changes:
|
|||||||
* `uid` {integer}
|
* `uid` {integer}
|
||||||
* `gid` {integer}
|
* `gid` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous chown(2). No arguments other than a possible exception are given
|
Asynchronous chown(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -731,6 +735,7 @@ changes:
|
|||||||
|
|
||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous close(2). No arguments other than a possible exception are given
|
Asynchronous close(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -980,6 +985,7 @@ deprecated: v1.0.0
|
|||||||
|
|
||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `exists` {Boolean}
|
||||||
|
|
||||||
Test whether or not the given path exists by checking with the file system.
|
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:
|
Then call the `callback` argument with either true or false. Example:
|
||||||
@ -1108,6 +1114,7 @@ changes:
|
|||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `mode` {integer}
|
* `mode` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous fchmod(2). No arguments other than a possible exception
|
Asynchronous fchmod(2). No arguments other than a possible exception
|
||||||
are given to the completion callback.
|
are given to the completion callback.
|
||||||
@ -1136,6 +1143,7 @@ changes:
|
|||||||
* `uid` {integer}
|
* `uid` {integer}
|
||||||
* `gid` {integer}
|
* `gid` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous fchown(2). No arguments other than a possible exception are given
|
Asynchronous fchown(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -1163,6 +1171,7 @@ changes:
|
|||||||
|
|
||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous fdatasync(2). No arguments other than a possible exception are
|
Asynchronous fdatasync(2). No arguments other than a possible exception are
|
||||||
given to the completion callback.
|
given to the completion callback.
|
||||||
@ -1188,6 +1197,8 @@ changes:
|
|||||||
|
|
||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `stats` {fs.Stats}
|
||||||
|
|
||||||
Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
|
Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
|
||||||
`stats` is an [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][],
|
`stats` is an [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][],
|
||||||
@ -1214,6 +1225,7 @@ changes:
|
|||||||
|
|
||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous fsync(2). No arguments other than a possible exception are given
|
Asynchronous fsync(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -1240,6 +1252,7 @@ changes:
|
|||||||
* `fd` {integer}
|
* `fd` {integer}
|
||||||
* `len` {integer} **Default:** `0`
|
* `len` {integer} **Default:** `0`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous ftruncate(2). No arguments other than a possible exception are
|
Asynchronous ftruncate(2). No arguments other than a possible exception are
|
||||||
given to the completion callback.
|
given to the completion callback.
|
||||||
@ -1313,6 +1326,7 @@ changes:
|
|||||||
* `atime` {integer}
|
* `atime` {integer}
|
||||||
* `mtime` {integer}
|
* `mtime` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Change the file timestamps of a file referenced by the supplied file
|
Change the file timestamps of a file referenced by the supplied file
|
||||||
descriptor.
|
descriptor.
|
||||||
@ -1349,6 +1363,7 @@ changes:
|
|||||||
* `path` {string|Buffer}
|
* `path` {string|Buffer}
|
||||||
* `mode` {integer}
|
* `mode` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous lchmod(2). No arguments other than a possible exception
|
Asynchronous lchmod(2). No arguments other than a possible exception
|
||||||
are given to the completion callback.
|
are given to the completion callback.
|
||||||
@ -1379,6 +1394,7 @@ changes:
|
|||||||
* `uid` {integer}
|
* `uid` {integer}
|
||||||
* `gid` {integer}
|
* `gid` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous lchown(2). No arguments other than a possible exception are given
|
Asynchronous lchown(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -1412,6 +1428,7 @@ changes:
|
|||||||
* `existingPath` {string|Buffer|URL}
|
* `existingPath` {string|Buffer|URL}
|
||||||
* `newPath` {string|Buffer|URL}
|
* `newPath` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous link(2). No arguments other than a possible exception are given to
|
Asynchronous link(2). No arguments other than a possible exception are given to
|
||||||
the completion callback.
|
the completion callback.
|
||||||
@ -1448,6 +1465,8 @@ changes:
|
|||||||
|
|
||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `stats` {fs.Stats}
|
||||||
|
|
||||||
Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
|
Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
|
||||||
`stats` is a [`fs.Stats`][] object. `lstat()` is identical to `stat()`,
|
`stats` is a [`fs.Stats`][] object. `lstat()` is identical to `stat()`,
|
||||||
@ -1485,6 +1504,7 @@ changes:
|
|||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `mode` {integer} **Default:** `0o777`
|
* `mode` {integer} **Default:** `0o777`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous mkdir(2). No arguments other than a possible exception are given
|
Asynchronous mkdir(2). No arguments other than a possible exception are given
|
||||||
to the completion callback. `mode` defaults to `0o777`.
|
to the completion callback. `mode` defaults to `0o777`.
|
||||||
@ -1521,6 +1541,8 @@ changes:
|
|||||||
* `options` {string|Object}
|
* `options` {string|Object}
|
||||||
* `encoding` {string} **Default:** `'utf8'`
|
* `encoding` {string} **Default:** `'utf8'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `folder` {string}
|
||||||
|
|
||||||
Creates a unique temporary directory.
|
Creates a unique temporary directory.
|
||||||
|
|
||||||
@ -1603,6 +1625,8 @@ changes:
|
|||||||
* `flags` {string|number}
|
* `flags` {string|number}
|
||||||
* `mode` {integer} **Default:** `0o666`
|
* `mode` {integer} **Default:** `0o666`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `fd` {integer}
|
||||||
|
|
||||||
Asynchronous file open. See open(2). `flags` can be:
|
Asynchronous file open. See open(2). `flags` can be:
|
||||||
|
|
||||||
@ -1721,6 +1745,9 @@ changes:
|
|||||||
* `length` {integer}
|
* `length` {integer}
|
||||||
* `position` {integer}
|
* `position` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `bytesRead` {integer}
|
||||||
|
* `buffer` {Buffer}
|
||||||
|
|
||||||
Read data from the file specified by `fd`.
|
Read data from the file specified by `fd`.
|
||||||
|
|
||||||
@ -1761,6 +1788,8 @@ changes:
|
|||||||
* `options` {string|Object}
|
* `options` {string|Object}
|
||||||
* `encoding` {string} **Default:** `'utf8'`
|
* `encoding` {string} **Default:** `'utf8'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `files` {string[]|Buffer[]}
|
||||||
|
|
||||||
Asynchronous readdir(3). Reads the contents of a directory.
|
Asynchronous readdir(3). Reads the contents of a directory.
|
||||||
The callback gets two arguments `(err, files)` where `files` is an array of
|
The callback gets two arguments `(err, files)` where `files` is an array of
|
||||||
@ -1819,6 +1848,8 @@ changes:
|
|||||||
* `encoding` {string|null} **Default:** `null`
|
* `encoding` {string|null} **Default:** `null`
|
||||||
* `flag` {string} **Default:** `'r'`
|
* `flag` {string} **Default:** `'r'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `data` {string|Buffer}
|
||||||
|
|
||||||
Asynchronously reads the entire contents of a file. Example:
|
Asynchronously reads the entire contents of a file. Example:
|
||||||
|
|
||||||
@ -1914,6 +1945,8 @@ changes:
|
|||||||
* `options` {string|Object}
|
* `options` {string|Object}
|
||||||
* `encoding` {string} **Default:** `'utf8'`
|
* `encoding` {string} **Default:** `'utf8'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `linkString` {string|Buffer}
|
||||||
|
|
||||||
Asynchronous readlink(2). The callback gets two arguments `(err,
|
Asynchronous readlink(2). The callback gets two arguments `(err,
|
||||||
linkString)`.
|
linkString)`.
|
||||||
@ -1989,6 +2022,8 @@ changes:
|
|||||||
* `options` {string|Object}
|
* `options` {string|Object}
|
||||||
* `encoding` {string} **Default:** `'utf8'`
|
* `encoding` {string} **Default:** `'utf8'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `resolvedPath` {string|Buffer}
|
||||||
|
|
||||||
Asynchronous realpath(3). The `callback` gets two arguments `(err,
|
Asynchronous realpath(3). The `callback` gets two arguments `(err,
|
||||||
resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
||||||
@ -2057,6 +2092,7 @@ changes:
|
|||||||
* `oldPath` {string|Buffer|URL}
|
* `oldPath` {string|Buffer|URL}
|
||||||
* `newPath` {string|Buffer|URL}
|
* `newPath` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous rename(2). No arguments other than a possible exception are given
|
Asynchronous rename(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -2093,6 +2129,7 @@ changes:
|
|||||||
|
|
||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous rmdir(2). No arguments other than a possible exception are given
|
Asynchronous rmdir(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -2133,6 +2170,8 @@ changes:
|
|||||||
|
|
||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `stats` {fs.Stats}
|
||||||
|
|
||||||
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
|
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
|
||||||
`stats` is an [`fs.Stats`][] object.
|
`stats` is an [`fs.Stats`][] object.
|
||||||
@ -2176,6 +2215,7 @@ changes:
|
|||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `type` {string} **Default:** `'file'`
|
* `type` {string} **Default:** `'file'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous symlink(2). No arguments other than a possible exception are given
|
Asynchronous symlink(2). No arguments other than a possible exception are given
|
||||||
to the completion callback. The `type` argument can be set to `'dir'`,
|
to the completion callback. The `type` argument can be set to `'dir'`,
|
||||||
@ -2222,6 +2262,7 @@ changes:
|
|||||||
* `path` {string|Buffer}
|
* `path` {string|Buffer}
|
||||||
* `len` {integer} **Default:** `0`
|
* `len` {integer} **Default:** `0`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous truncate(2). No arguments other than a possible exception are
|
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
|
given to the completion callback. A file descriptor can also be passed as the
|
||||||
@ -2254,6 +2295,7 @@ changes:
|
|||||||
|
|
||||||
* `path` {string|Buffer|URL}
|
* `path` {string|Buffer|URL}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronous unlink(2). No arguments other than a possible exception are given
|
Asynchronous unlink(2). No arguments other than a possible exception are given
|
||||||
to the completion callback.
|
to the completion callback.
|
||||||
@ -2279,6 +2321,8 @@ added: v0.1.31
|
|||||||
|
|
||||||
* `filename` {string|Buffer}
|
* `filename` {string|Buffer}
|
||||||
* `listener` {Function|undefined} **Default:** `undefined`
|
* `listener` {Function|undefined} **Default:** `undefined`
|
||||||
|
* `eventType` {string}
|
||||||
|
* `filename` {string|Buffer}
|
||||||
|
|
||||||
Stop watching for changes on `filename`. If `listener` is specified, only that
|
Stop watching for changes on `filename`. If `listener` is specified, only that
|
||||||
particular listener is removed. Otherwise, *all* listeners are removed,
|
particular listener is removed. Otherwise, *all* listeners are removed,
|
||||||
@ -2313,6 +2357,7 @@ changes:
|
|||||||
* `atime` {integer}
|
* `atime` {integer}
|
||||||
* `mtime` {integer}
|
* `mtime` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Change file timestamps of the file referenced by the supplied path.
|
Change file timestamps of the file referenced by the supplied path.
|
||||||
|
|
||||||
@ -2369,6 +2414,8 @@ changes:
|
|||||||
* `encoding` {string} Specifies the character encoding to be used for the
|
* `encoding` {string} Specifies the character encoding to be used for the
|
||||||
filename passed to the listener. **Default:** `'utf8'`
|
filename passed to the listener. **Default:** `'utf8'`
|
||||||
* `listener` {Function|undefined} **Default:** `undefined`
|
* `listener` {Function|undefined} **Default:** `undefined`
|
||||||
|
* `eventType` {string}
|
||||||
|
* `filename` {string|Buffer}
|
||||||
|
|
||||||
Watch for changes on `filename`, where `filename` is either a file or a
|
Watch for changes on `filename`, where `filename` is either a file or a
|
||||||
directory. The returned object is a [`fs.FSWatcher`][].
|
directory. The returned object is a [`fs.FSWatcher`][].
|
||||||
@ -2471,6 +2518,8 @@ changes:
|
|||||||
* `persistent` {boolean} **Default:** `true`
|
* `persistent` {boolean} **Default:** `true`
|
||||||
* `interval` {integer} **Default:** `5007`
|
* `interval` {integer} **Default:** `5007`
|
||||||
* `listener` {Function}
|
* `listener` {Function}
|
||||||
|
* `current` {fs.Stats}
|
||||||
|
* `previous` {fs.Stats}
|
||||||
|
|
||||||
Watch for changes on `filename`. The callback `listener` will be called each
|
Watch for changes on `filename`. The callback `listener` will be called each
|
||||||
time the file is accessed.
|
time the file is accessed.
|
||||||
@ -2530,6 +2579,9 @@ changes:
|
|||||||
* `length` {integer}
|
* `length` {integer}
|
||||||
* `position` {integer}
|
* `position` {integer}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `bytesWritten` {integer}
|
||||||
|
* `buffer` {Buffer|Uint8Array}
|
||||||
|
|
||||||
Write `buffer` to the file specified by `fd`.
|
Write `buffer` to the file specified by `fd`.
|
||||||
|
|
||||||
@ -2572,6 +2624,9 @@ changes:
|
|||||||
* `position` {integer}
|
* `position` {integer}
|
||||||
* `encoding` {string}
|
* `encoding` {string}
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
* `written` {integer}
|
||||||
|
* `string` {string}
|
||||||
|
|
||||||
Write `string` to the file specified by `fd`. If `string` is not a string, then
|
Write `string` to the file specified by `fd`. If `string` is not a string, then
|
||||||
the value will be coerced to one.
|
the value will be coerced to one.
|
||||||
@ -2621,6 +2676,7 @@ changes:
|
|||||||
* `mode` {integer} **Default:** `0o666`
|
* `mode` {integer} **Default:** `0o666`
|
||||||
* `flag` {string} **Default:** `'w'`
|
* `flag` {string} **Default:** `'w'`
|
||||||
* `callback` {Function}
|
* `callback` {Function}
|
||||||
|
* `err` {Error}
|
||||||
|
|
||||||
Asynchronously writes data to a file, replacing the file if it already exists.
|
Asynchronously writes data to a file, replacing the file if it already exists.
|
||||||
`data` can be a string or a buffer.
|
`data` can be a string or a buffer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user