From 9830165e34a59c7d4418f30cd13fc4da42b7945e Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Sun, 8 Oct 2023 13:06:58 +0300 Subject: [PATCH] doc: use precise promise terminology in fs See https://github.com/nodejs/node/pull/50028 for context - this also has the added benefit of reducing the amount of times we use resolving a promise vs resolving a path. Note this document already used `fulfills` in many cases and I kept resolves (for promises) in some cases where it made sense to me from a technical point of view. PR-URL: https://github.com/nodejs/node/pull/50029 Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow --- doc/api/fs.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 56f693656eddb7..ab3a7e9026c37e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -657,7 +657,7 @@ added: v10.0.0 * Returns: {Promise} Change the file system timestamps of the object referenced by the {FileHandle} -then resolves the promise with no arguments upon success. +then fulfills the promise with no arguments upon success. #### `filehandle.write(buffer, offset[, length[, position]])` @@ -683,14 +683,14 @@ changes: Write `buffer` to the file. -The promise is resolved with an object containing two properties: +The promise is fulfilled with an object containing two properties: * `bytesWritten` {integer} the number of bytes written * `buffer` {Buffer|TypedArray|DataView} a reference to the `buffer` written. It is unsafe to use `filehandle.write()` multiple times on the same file -without waiting for the promise to be resolved (or rejected). For this +without waiting for the promise to be fulfilled (or rejected). For this scenario, use [`filehandle.createWriteStream()`][]. On Linux, positional writes do not work when the file is opened in append mode. @@ -740,13 +740,13 @@ changes: Write `string` to the file. If `string` is not a string, the promise is rejected with an error. -The promise is resolved with an object containing two properties: +The promise is fulfilled with an object containing two properties: * `bytesWritten` {integer} the number of bytes written * `buffer` {string} a reference to the `string` written. It is unsafe to use `filehandle.write()` multiple times on the same file -without waiting for the promise to be resolved (or rejected). For this +without waiting for the promise to be fulfilled (or rejected). For this scenario, use [`filehandle.createWriteStream()`][]. On Linux, positional writes do not work when the file is opened in append mode. @@ -777,14 +777,14 @@ changes: Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an {AsyncIterable}, or an {Iterable} object. -The promise is resolved with no arguments upon success. +The promise is fulfilled with no arguments upon success. If `options` is a string, then it specifies the `encoding`. The {FileHandle} has to support writing. It is unsafe to use `filehandle.writeFile()` multiple times on the same file -without waiting for the promise to be resolved (or rejected). +without waiting for the promise to be fulfilled (or rejected). If one or more `filehandle.write()` calls are made on a file handle and then a `filehandle.writeFile()` call is made, the data will be written from the @@ -805,14 +805,14 @@ added: v12.9.0 Write an array of {ArrayBufferView}s to the file. -The promise is resolved with an object containing a two properties: +The promise is fulfilled with an object containing a two properties: * `bytesWritten` {integer} the number of bytes written * `buffers` {Buffer\[]|TypedArray\[]|DataView\[]} a reference to the `buffers` input. It is unsafe to call `writev()` multiple times on the same file without waiting -for the promise to be resolved (or rejected). +for the promise to be fulfilled (or rejected). 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 @@ -846,7 +846,7 @@ or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK | fs.constants.R_OK`). Check [File access constants][] for possible values of `mode`. -If the accessibility check is successful, the promise is resolved with no +If the accessibility check is successful, the promise is fulfilled with no value. If any of the accessibility checks fail, the promise is rejected with an {Error} object. The following example checks if the file `/etc/passwd` can be read and written by the current process. @@ -1309,7 +1309,7 @@ object with an `encoding` property specifying the character encoding to use for the filenames. If the `encoding` is set to `'buffer'`, the filenames returned will be passed as {Buffer} objects. -If `options.withFileTypes` is set to `true`, the resolved array will contain +If `options.withFileTypes` is set to `true`, the returned array will contain {fs.Dirent} objects. ```mjs @@ -1423,7 +1423,7 @@ added: v10.0.0 * Returns: {Promise} Fulfills with the `linkString` upon success. Reads the contents of the symbolic link referred to by `path`. See the POSIX -readlink(2) documentation for more detail. The promise is resolved with the +readlink(2) documentation for more detail. The promise is fulfilled with the `linkString` upon success. The optional `options` argument can be a string specifying an encoding, or an @@ -6319,7 +6319,7 @@ added: v12.12.0 Asynchronously close the directory's underlying resource handle. Subsequent reads will result in errors. -A promise is returned that will be resolved after the resource has been +A promise is returned that will be fulfilled after the resource has been closed. #### `dir.close(callback)` @@ -6373,7 +6373,7 @@ added: v12.12.0 Asynchronously read the next directory entry via readdir(3) as an {fs.Dirent}. -A promise is returned that will be resolved with an {fs.Dirent}, or `null` +A promise is returned that will be fulfilled with an {fs.Dirent}, or `null` if there are no more directory entries to read. Directory entries returned by this function are in no particular order as