|
45 | 45 | }
|
46 | 46 | ```
|
47 | 47 |
|
48 |
| -Note that there is no guaranteed ordering when using asynchronous methods. |
49 |
| -So the following is prone to error because the `fs.stat()` operation may |
50 |
| -complete before the `fs.rename()` operation. |
| 48 | +There is no guaranteed ordering when using asynchronous methods. So the |
| 49 | +following is prone to error because the `fs.stat()` operation may complete |
| 50 | +before the `fs.rename()` operation: |
51 | 51 |
|
52 | 52 | ```js
|
53 | 53 | fs.rename('/tmp/hello', '/tmp/world', (err) => {
|
@@ -150,8 +150,8 @@ fs.open(Buffer.from('/open/some/file.txt'), 'r', (err, fd) => {
|
150 | 150 | });
|
151 | 151 | ```
|
152 | 152 |
|
153 |
| -*Note:* On Windows Node.js follows the concept of per-drive working directory. |
154 |
| -This behavior can be observed when using a drive path without a backslash. For |
| 153 | +On Windows, Node.js follows the concept of per-drive working directory. This |
| 154 | +behavior can be observed when using a drive path without a backslash. For |
155 | 155 | example `fs.readdirSync('c:\\')` can potentially return a different result than
|
156 | 156 | `fs.readdirSync('c:')`. For more information, see
|
157 | 157 | [this MSDN page][MSDN-Rel-Path].
|
@@ -278,9 +278,9 @@ eventually cause an application to crash.
|
278 | 278 |
|
279 | 279 | ## Threadpool Usage
|
280 | 280 |
|
281 |
| -Note that all file system APIs except `fs.FSWatcher()` and those that are |
282 |
| -explicitly synchronous use libuv's threadpool, which can have surprising and |
283 |
| -negative performance implications for some applications, see the |
| 281 | +All file system APIs except `fs.FSWatcher()` and those that are explicitly |
| 282 | +synchronous use libuv's threadpool, which can have surprising and negative |
| 283 | +performance implications for some applications. See the |
284 | 284 | [`UV_THREADPOOL_SIZE`][] documentation for more information.
|
285 | 285 |
|
286 | 286 | ## Class: fs.FSWatcher
|
@@ -689,15 +689,13 @@ The times in the stat object have the following semantics:
|
689 | 689 | * `birthtime` "Birth Time" - Time of file creation. Set once when the
|
690 | 690 | file is created. On filesystems where birthtime is not available,
|
691 | 691 | this field may instead hold either the `ctime` or
|
692 |
| - `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). Note that this |
693 |
| - value may be greater than `atime` or `mtime` in this case. On Darwin |
694 |
| - and other FreeBSD variants, also set if the `atime` is explicitly |
695 |
| - set to an earlier value than the current `birthtime` using the |
696 |
| - utimes(2) system call. |
| 692 | + `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). This value may be greater |
| 693 | + than `atime` or `mtime` in this case. On Darwin and other FreeBSD variants, |
| 694 | + also set if the `atime` is explicitly set to an earlier value than the current |
| 695 | + `birthtime` using the utimes(2) system call. |
697 | 696 |
|
698 |
| -Prior to Node.js v0.12, the `ctime` held the `birthtime` on Windows |
699 |
| -systems. Note that as of v0.12, `ctime` is not "creation time", and |
700 |
| -on Unix systems, it never was. |
| 697 | +Prior to Node.js 0.12, the `ctime` held the `birthtime` on Windows systems. As |
| 698 | +of 0.12, `ctime` is not "creation time", and on Unix systems, it never was. |
701 | 699 |
|
702 | 700 | ## Class: fs.WriteStream
|
703 | 701 | <!-- YAML
|
@@ -1117,11 +1115,10 @@ For example, the octal value `0o765` means:
|
1117 | 1115 | * The group may read and write the file.
|
1118 | 1116 | * Others may read and execute the file.
|
1119 | 1117 |
|
1120 |
| -Note: When using raw numbers where file modes are expected, |
1121 |
| -any value larger than `0o777` may result in platform-specific |
1122 |
| -behaviors that are not supported to work consistently. |
1123 |
| -Therefore constants like `S_ISVTX`, `S_ISGID` or `S_ISUID` are |
1124 |
| -not exposed in `fs.constants`. |
| 1118 | +When using raw numbers where file modes are expected, any value larger than |
| 1119 | +`0o777` may result in platform-specific behaviors that are not supported to work |
| 1120 | +consistently. Therefore constants like `S_ISVTX`, `S_ISGID` or `S_ISUID` are not |
| 1121 | +exposed in `fs.constants`. |
1125 | 1122 |
|
1126 | 1123 | Caveats: on Windows only the write permission can be changed, and the
|
1127 | 1124 | distinction among the permissions of group, owner or others is not
|
@@ -1378,8 +1375,8 @@ The `encoding` can be any one of those accepted by [`Buffer`][].
|
1378 | 1375 |
|
1379 | 1376 | If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
|
1380 | 1377 | the specified file descriptor. This means that no `'open'` event will be
|
1381 |
| -emitted. Note that `fd` should be blocking; non-blocking `fd`s should be passed |
1382 |
| -to [`net.Socket`][]. |
| 1378 | +emitted. `fd` should be blocking; non-blocking `fd`s should be passed to |
| 1379 | +[`net.Socket`][]. |
1383 | 1380 |
|
1384 | 1381 | If `autoClose` is false, then the file descriptor won't be closed, even if
|
1385 | 1382 | there's an error. It is the application's responsibility to close it and make
|
@@ -1442,8 +1439,8 @@ file descriptor leak.
|
1442 | 1439 |
|
1443 | 1440 | Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the
|
1444 | 1441 | `path` argument and will use the specified file descriptor. This means that no
|
1445 |
| -`'open'` event will be emitted. Note that `fd` should be blocking; non-blocking |
1446 |
| -`fd`s should be passed to [`net.Socket`][]. |
| 1442 | +`'open'` event will be emitted. `fd` should be blocking; non-blocking `fd`s |
| 1443 | +should be passed to [`net.Socket`][]. |
1447 | 1444 |
|
1448 | 1445 | If `options` is a string, then it specifies the encoding.
|
1449 | 1446 |
|
@@ -1473,11 +1470,11 @@ fs.exists('/etc/passwd', (exists) => {
|
1473 | 1470 | });
|
1474 | 1471 | ```
|
1475 | 1472 |
|
1476 |
| -**Note that the parameter to this callback is not consistent with other |
1477 |
| -Node.js callbacks.** Normally, the first parameter to a Node.js callback is |
1478 |
| -an `err` parameter, optionally followed by other parameters. The |
1479 |
| -`fs.exists()` callback has only one boolean parameter. This is one reason |
1480 |
| -`fs.access()` is recommended instead of `fs.exists()`. |
| 1473 | +**The parameters for this callback are not consistent with other Node.js |
| 1474 | +callbacks.** Normally, the first parameter to a Node.js callback is an `err` |
| 1475 | +parameter, optionally followed by other parameters. The `fs.exists()` callback |
| 1476 | +has only one boolean parameter. This is one reason `fs.access()` is recommended |
| 1477 | +instead of `fs.exists()`. |
1481 | 1478 |
|
1482 | 1479 | Using `fs.exists()` to check for the existence of a file before calling
|
1483 | 1480 | `fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing
|
@@ -1573,10 +1570,9 @@ changes:
|
1573 | 1570 | Synchronous version of [`fs.exists()`][].
|
1574 | 1571 | Returns `true` if the path exists, `false` otherwise.
|
1575 | 1572 |
|
1576 |
| -Note that `fs.exists()` is deprecated, but `fs.existsSync()` is not. |
1577 |
| -(The `callback` parameter to `fs.exists()` accepts parameters that are |
1578 |
| -inconsistent with other Node.js callbacks. `fs.existsSync()` does not use |
1579 |
| -a callback.) |
| 1573 | +`fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback` |
| 1574 | +parameter to `fs.exists()` accepts parameters that are inconsistent with other |
| 1575 | +Node.js callbacks. `fs.existsSync()` does not use a callback. |
1580 | 1576 |
|
1581 | 1577 | ## fs.fchmod(fd, mode, callback)
|
1582 | 1578 | <!-- YAML
|
@@ -2149,9 +2145,8 @@ fs.mkdtemp(tmpDir, (err, folder) => {
|
2149 | 2145 | if (err) throw err;
|
2150 | 2146 | console.log(folder);
|
2151 | 2147 | // Will print something similar to `/tmpabc123`.
|
2152 |
| - // Note that a new temporary directory is created |
2153 |
| - // at the file system root rather than *within* |
2154 |
| - // the /tmp directory. |
| 2148 | + // A new temporary directory is created at the file system root |
| 2149 | + // rather than *within* the /tmp directory. |
2155 | 2150 | });
|
2156 | 2151 |
|
2157 | 2152 | // This method is *CORRECT*:
|
@@ -2204,8 +2199,8 @@ changes:
|
2204 | 2199 | Asynchronous file open. See open(2).
|
2205 | 2200 |
|
2206 | 2201 | `mode` sets the file mode (permission and sticky bits), but only if the file was
|
2207 |
| -created. Note that on Windows only the write permission can be manipulated, |
2208 |
| -see [`fs.chmod()`][]. |
| 2202 | +created. On Windows, only the write permission can be manipulated; see |
| 2203 | +[`fs.chmod()`][]. |
2209 | 2204 |
|
2210 | 2205 | The callback gets two arguments `(err, fd)`.
|
2211 | 2206 |
|
@@ -2843,9 +2838,9 @@ changes:
|
2843 | 2838 | Asynchronous symlink(2). No arguments other than a possible exception are given
|
2844 | 2839 | to the completion callback. The `type` argument can be set to `'dir'`,
|
2845 | 2840 | `'file'`, or `'junction'` and is only available on
|
2846 |
| -Windows (ignored on other platforms). Note that Windows junction points require |
2847 |
| -the destination path to be absolute. When using `'junction'`, the `target` |
2848 |
| -argument will automatically be normalized to absolute path. |
| 2841 | +Windows (ignored on other platforms). Windows junction points require the |
| 2842 | +destination path to be absolute. When using `'junction'`, the `target` argument |
| 2843 | +will automatically be normalized to absolute path. |
2849 | 2844 |
|
2850 | 2845 | Here is an example below:
|
2851 | 2846 |
|
@@ -3086,10 +3081,10 @@ The listener callback gets two arguments `(eventType, filename)`. `eventType`
|
3086 | 3081 | is either `'rename'` or `'change'`, and `filename` is the name of the file
|
3087 | 3082 | which triggered the event.
|
3088 | 3083 |
|
3089 |
| -Note that on most platforms, `'rename'` is emitted whenever a filename appears |
3090 |
| -or disappears in the directory. |
| 3084 | +On most platforms, `'rename'` is emitted whenever a filename appears or |
| 3085 | +disappears in the directory. |
3091 | 3086 |
|
3092 |
| -Also note the listener callback is attached to the `'change'` event fired by |
| 3087 | +The listener callback is attached to the `'change'` event fired by |
3093 | 3088 | [`fs.FSWatcher`][], but it is not the same thing as the `'change'` value of
|
3094 | 3089 | `eventType`.
|
3095 | 3090 |
|
@@ -3266,9 +3261,8 @@ The callback will be given three arguments `(err, bytesWritten, buffer)` where
|
3266 | 3261 | If this method is invoked as its [`util.promisify()`][]ed version, it returns
|
3267 | 3262 | a `Promise` for an `Object` with `bytesWritten` and `buffer` properties.
|
3268 | 3263 |
|
3269 |
| -Note that it is unsafe to use `fs.write` multiple times on the same file |
3270 |
| -without waiting for the callback. For this scenario, |
3271 |
| -`fs.createWriteStream` is strongly recommended. |
| 3264 | +It is unsafe to use `fs.write()` multiple times on the same file without waiting |
| 3265 | +for the callback. For this scenario, `fs.createWriteStream()` is recommended. |
3272 | 3266 |
|
3273 | 3267 | On Linux, positional writes don't work when the file is opened in append mode.
|
3274 | 3268 | The kernel ignores the position argument and always appends the data to
|
@@ -3310,12 +3304,12 @@ the current position. See pwrite(2).
|
3310 | 3304 | `encoding` is the expected string encoding.
|
3311 | 3305 |
|
3312 | 3306 | The callback will receive the arguments `(err, written, string)` where `written`
|
3313 |
| -specifies how many _bytes_ the passed string required to be written. Note that |
3314 |
| -bytes written is not the same as string characters. See [`Buffer.byteLength`][]. |
| 3307 | +specifies how many _bytes_ the passed string required to be written. Bytes |
| 3308 | +written is not necessarily the same as string characters written. See |
| 3309 | +[`Buffer.byteLength`][]. |
3315 | 3310 |
|
3316 |
| -Note that it is unsafe to use `fs.write` multiple times on the same file |
3317 |
| -without waiting for the callback. For this scenario, |
3318 |
| -`fs.createWriteStream` is strongly recommended. |
| 3311 | +It is unsafe to use `fs.write()` multiple times on the same file without waiting |
| 3312 | +for the callback. For this scenario, `fs.createWriteStream()` is recommended. |
3319 | 3313 |
|
3320 | 3314 | On Linux, positional writes don't work when the file is opened in append mode.
|
3321 | 3315 | The kernel ignores the position argument and always appends the data to
|
@@ -3372,9 +3366,9 @@ fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
|
3372 | 3366 |
|
3373 | 3367 | Any specified file descriptor has to support writing.
|
3374 | 3368 |
|
3375 |
| -Note that it is unsafe to use `fs.writeFile` multiple times on the same file |
3376 |
| -without waiting for the callback. For this scenario, |
3377 |
| -`fs.createWriteStream` is strongly recommended. |
| 3369 | +It is unsafe to use `fs.writeFile()` multiple times on the same file without |
| 3370 | +waiting for the callback. For this scenario, `fs.createWriteStream()` is |
| 3371 | +recommended. |
3378 | 3372 |
|
3379 | 3373 | If a file descriptor is specified as the `file`, it will not be closed
|
3380 | 3374 | automatically.
|
@@ -4161,9 +4155,9 @@ Creates a symbolic link then resolves the `Promise` with no arguments upon
|
4161 | 4155 | success.
|
4162 | 4156 |
|
4163 | 4157 | The `type` argument is only used on Windows platforms and can be one of `'dir'`,
|
4164 |
| -`'file'`, or `'junction'`. Note that Windows junction |
4165 |
| -points require the destination path to be absolute. When using `'junction'`, |
4166 |
| -the `target` argument will automatically be normalized to absolute path. |
| 4158 | +`'file'`, or `'junction'`. Windows junction points require the destination path |
| 4159 | +to be absolute. When using `'junction'`, the `target` argument will |
| 4160 | +automatically be normalized to absolute path. |
4167 | 4161 |
|
4168 | 4162 | ### fsPromises.truncate(path[, len])
|
4169 | 4163 | <!-- YAML
|
@@ -4525,9 +4519,9 @@ string:
|
4525 | 4519 | skipping the potentially stale local cache. It has a very real impact on
|
4526 | 4520 | I/O performance so using this flag is not recommended unless it is needed.
|
4527 | 4521 |
|
4528 |
| - Note that this doesn't turn `fs.open()` or `fsPromises.open()` into a |
4529 |
| - synchronous blocking call. If synchronous operation is desired, something |
4530 |
| - like `fs.openSync()` should be used. |
| 4522 | + This doesn't turn `fs.open()` or `fsPromises.open()` into a synchronous |
| 4523 | + blocking call. If synchronous operation is desired, something like |
| 4524 | + `fs.openSync()` should be used. |
4531 | 4525 |
|
4532 | 4526 | * `'w'` - Open file for writing.
|
4533 | 4527 | The file is created (if it does not exist) or truncated (if it exists).
|
|
0 commit comments