|
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 |
@@ -1373,8 +1370,8 @@ The `encoding` can be any one of those accepted by [`Buffer`][]. |
1373 | 1370 |
|
1374 | 1371 | If `fd` is specified, `ReadStream` will ignore the `path` argument and will use |
1375 | 1372 | the specified file descriptor. This means that no `'open'` event will be |
1376 | | -emitted. Note that `fd` should be blocking; non-blocking `fd`s should be passed |
1377 | | -to [`net.Socket`][]. |
| 1373 | +emitted. `fd` should be blocking; non-blocking `fd`s should be passed to |
| 1374 | +[`net.Socket`][]. |
1378 | 1375 |
|
1379 | 1376 | If `autoClose` is false, then the file descriptor won't be closed, even if |
1380 | 1377 | there's an error. It is the application's responsibility to close it and make |
@@ -1437,8 +1434,8 @@ file descriptor leak. |
1437 | 1434 |
|
1438 | 1435 | Like [`ReadStream`][], if `fd` is specified, [`WriteStream`][] will ignore the |
1439 | 1436 | `path` argument and will use the specified file descriptor. This means that no |
1440 | | -`'open'` event will be emitted. Note that `fd` should be blocking; non-blocking |
1441 | | -`fd`s should be passed to [`net.Socket`][]. |
| 1437 | +`'open'` event will be emitted. `fd` should be blocking; non-blocking `fd`s |
| 1438 | +should be passed to [`net.Socket`][]. |
1442 | 1439 |
|
1443 | 1440 | If `options` is a string, then it specifies the encoding. |
1444 | 1441 |
|
@@ -1468,11 +1465,11 @@ fs.exists('/etc/passwd', (exists) => { |
1468 | 1465 | }); |
1469 | 1466 | ``` |
1470 | 1467 |
|
1471 | | -**Note that the parameter to this callback is not consistent with other |
1472 | | -Node.js callbacks.** Normally, the first parameter to a Node.js callback is |
1473 | | -an `err` parameter, optionally followed by other parameters. The |
1474 | | -`fs.exists()` callback has only one boolean parameter. This is one reason |
1475 | | -`fs.access()` is recommended instead of `fs.exists()`. |
| 1468 | +**The parameters for this callback are not consistent with other Node.js |
| 1469 | +callbacks.** Normally, the first parameter to a Node.js callback is an `err` |
| 1470 | +parameter, optionally followed by other parameters. The `fs.exists()` callback |
| 1471 | +has only one boolean parameter. This is one reason `fs.access()` is recommended |
| 1472 | +instead of `fs.exists()`. |
1476 | 1473 |
|
1477 | 1474 | Using `fs.exists()` to check for the existence of a file before calling |
1478 | 1475 | `fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing |
@@ -1568,10 +1565,9 @@ changes: |
1568 | 1565 | Synchronous version of [`fs.exists()`][]. |
1569 | 1566 | Returns `true` if the path exists, `false` otherwise. |
1570 | 1567 |
|
1571 | | -Note that `fs.exists()` is deprecated, but `fs.existsSync()` is not. |
1572 | | -(The `callback` parameter to `fs.exists()` accepts parameters that are |
1573 | | -inconsistent with other Node.js callbacks. `fs.existsSync()` does not use |
1574 | | -a callback.) |
| 1568 | +`fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback` |
| 1569 | +parameter to `fs.exists()` accepts parameters that are inconsistent with other |
| 1570 | +Node.js callbacks. `fs.existsSync()` does not use a callback. |
1575 | 1571 |
|
1576 | 1572 | ## fs.fchmod(fd, mode, callback) |
1577 | 1573 | <!-- YAML |
@@ -2144,9 +2140,8 @@ fs.mkdtemp(tmpDir, (err, folder) => { |
2144 | 2140 | if (err) throw err; |
2145 | 2141 | console.log(folder); |
2146 | 2142 | // Will print something similar to `/tmpabc123`. |
2147 | | - // Note that a new temporary directory is created |
2148 | | - // at the file system root rather than *within* |
2149 | | - // the /tmp directory. |
| 2143 | + // A new temporary directory is created at the file system root |
| 2144 | + // rather than *within* the /tmp directory. |
2150 | 2145 | }); |
2151 | 2146 |
|
2152 | 2147 | // This method is *CORRECT*: |
@@ -2199,8 +2194,8 @@ changes: |
2199 | 2194 | Asynchronous file open. See open(2). |
2200 | 2195 |
|
2201 | 2196 | `mode` sets the file mode (permission and sticky bits), but only if the file was |
2202 | | -created. Note that on Windows only the write permission can be manipulated, |
2203 | | -see [`fs.chmod()`][]. |
| 2197 | +created. On Windows, only the write permission can be manipulated; see |
| 2198 | +[`fs.chmod()`][]. |
2204 | 2199 |
|
2205 | 2200 | The callback gets two arguments `(err, fd)`. |
2206 | 2201 |
|
@@ -2838,9 +2833,9 @@ changes: |
2838 | 2833 | Asynchronous symlink(2). No arguments other than a possible exception are given |
2839 | 2834 | to the completion callback. The `type` argument can be set to `'dir'`, |
2840 | 2835 | `'file'`, or `'junction'` and is only available on |
2841 | | -Windows (ignored on other platforms). Note that Windows junction points require |
2842 | | -the destination path to be absolute. When using `'junction'`, the `target` |
2843 | | -argument will automatically be normalized to absolute path. |
| 2836 | +Windows (ignored on other platforms). Windows junction points require the |
| 2837 | +destination path to be absolute. When using `'junction'`, the `target` argument |
| 2838 | +will automatically be normalized to absolute path. |
2844 | 2839 |
|
2845 | 2840 | Here is an example below: |
2846 | 2841 |
|
@@ -3081,10 +3076,10 @@ The listener callback gets two arguments `(eventType, filename)`. `eventType` |
3081 | 3076 | is either `'rename'` or `'change'`, and `filename` is the name of the file |
3082 | 3077 | which triggered the event. |
3083 | 3078 |
|
3084 | | -Note that on most platforms, `'rename'` is emitted whenever a filename appears |
3085 | | -or disappears in the directory. |
| 3079 | +On most platforms, `'rename'` is emitted whenever a filename appears or |
| 3080 | +disappears in the directory. |
3086 | 3081 |
|
3087 | | -Also note the listener callback is attached to the `'change'` event fired by |
| 3082 | +The listener callback is attached to the `'change'` event fired by |
3088 | 3083 | [`fs.FSWatcher`][], but it is not the same thing as the `'change'` value of |
3089 | 3084 | `eventType`. |
3090 | 3085 |
|
@@ -3261,9 +3256,8 @@ The callback will be given three arguments `(err, bytesWritten, buffer)` where |
3261 | 3256 | If this method is invoked as its [`util.promisify()`][]ed version, it returns |
3262 | 3257 | a `Promise` for an `Object` with `bytesWritten` and `buffer` properties. |
3263 | 3258 |
|
3264 | | -Note that it is unsafe to use `fs.write` multiple times on the same file |
3265 | | -without waiting for the callback. For this scenario, |
3266 | | -`fs.createWriteStream` is strongly recommended. |
| 3259 | +It is unsafe to use `fs.write()` multiple times on the same file without waiting |
| 3260 | +for the callback. For this scenario, `fs.createWriteStream()` is recommended. |
3267 | 3261 |
|
3268 | 3262 | On Linux, positional writes don't work when the file is opened in append mode. |
3269 | 3263 | The kernel ignores the position argument and always appends the data to |
@@ -3305,12 +3299,12 @@ the current position. See pwrite(2). |
3305 | 3299 | `encoding` is the expected string encoding. |
3306 | 3300 |
|
3307 | 3301 | The callback will receive the arguments `(err, written, string)` where `written` |
3308 | | -specifies how many _bytes_ the passed string required to be written. Note that |
3309 | | -bytes written is not the same as string characters. See [`Buffer.byteLength`][]. |
| 3302 | +specifies how many _bytes_ the passed string required to be written. Bytes |
| 3303 | +written is not necessarily the same as string characters written. See |
| 3304 | +[`Buffer.byteLength`][]. |
3310 | 3305 |
|
3311 | | -Note that it is unsafe to use `fs.write` multiple times on the same file |
3312 | | -without waiting for the callback. For this scenario, |
3313 | | -`fs.createWriteStream` is strongly recommended. |
| 3306 | +It is unsafe to use `fs.write()` multiple times on the same file without waiting |
| 3307 | +for the callback. For this scenario, `fs.createWriteStream()` is recommended. |
3314 | 3308 |
|
3315 | 3309 | On Linux, positional writes don't work when the file is opened in append mode. |
3316 | 3310 | The kernel ignores the position argument and always appends the data to |
@@ -3367,9 +3361,9 @@ fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback); |
3367 | 3361 |
|
3368 | 3362 | Any specified file descriptor has to support writing. |
3369 | 3363 |
|
3370 | | -Note that it is unsafe to use `fs.writeFile` multiple times on the same file |
3371 | | -without waiting for the callback. For this scenario, |
3372 | | -`fs.createWriteStream` is strongly recommended. |
| 3364 | +It is unsafe to use `fs.writeFile()` multiple times on the same file without |
| 3365 | +waiting for the callback. For this scenario, `fs.createWriteStream()` is |
| 3366 | +recommended. |
3373 | 3367 |
|
3374 | 3368 | If a file descriptor is specified as the `file`, it will not be closed |
3375 | 3369 | automatically. |
@@ -4156,9 +4150,9 @@ Creates a symbolic link then resolves the `Promise` with no arguments upon |
4156 | 4150 | success. |
4157 | 4151 |
|
4158 | 4152 | The `type` argument is only used on Windows platforms and can be one of `'dir'`, |
4159 | | -`'file'`, or `'junction'`. Note that Windows junction |
4160 | | -points require the destination path to be absolute. When using `'junction'`, |
4161 | | -the `target` argument will automatically be normalized to absolute path. |
| 4153 | +`'file'`, or `'junction'`. Windows junction points require the destination path |
| 4154 | +to be absolute. When using `'junction'`, the `target` argument will |
| 4155 | +automatically be normalized to absolute path. |
4162 | 4156 |
|
4163 | 4157 | ### fsPromises.truncate(path[, len]) |
4164 | 4158 | <!-- YAML |
@@ -4520,9 +4514,9 @@ string: |
4520 | 4514 | skipping the potentially stale local cache. It has a very real impact on |
4521 | 4515 | I/O performance so using this flag is not recommended unless it is needed. |
4522 | 4516 |
|
4523 | | - Note that this doesn't turn `fs.open()` or `fsPromises.open()` into a |
4524 | | - synchronous blocking call. If synchronous operation is desired, something |
4525 | | - like `fs.openSync()` should be used. |
| 4517 | + This doesn't turn `fs.open()` or `fsPromises.open()` into a synchronous |
| 4518 | + blocking call. If synchronous operation is desired, something like |
| 4519 | + `fs.openSync()` should be used. |
4526 | 4520 |
|
4527 | 4521 | * `'w'` - Open file for writing. |
4528 | 4522 | The file is created (if it does not exist) or truncated (if it exists). |
|
0 commit comments