@@ -186,7 +186,7 @@ added: v10.0.0
186
186
* ` data ` {string|Buffer|TypedArray|DataView}
187
187
* ` options ` {Object|string}
188
188
* ` encoding ` {string|null} ** Default:** ` 'utf8' `
189
- * Returns: {Promise}
189
+ * Returns: {Promise} Fulfills with ` undefined ` upon success.
190
190
191
191
Alias of [ ` filehandle.writeFile() ` ] [ ] .
192
192
@@ -199,33 +199,31 @@ to with [`fsPromises.open()`][]. Therefore, this is equivalent to
199
199
added: v10.0.0
200
200
-->
201
201
202
- * ` mode ` {integer}
203
- * Returns: {Promise}
202
+ * ` mode ` {integer} the file mode bit mask.
203
+ * Returns: {Promise} Fulfills with ` undefined ` upon success.
204
204
205
- Modifies the permissions on the file. The promise is resolved with no
206
- arguments upon success.
205
+ Modifies the permissions on the file. See chmod(2).
207
206
208
207
#### ` filehandle.chown(uid, gid) `
209
208
<!-- YAML
210
209
added: v10.0.0
211
210
-->
212
211
213
- * ` uid ` {integer}
214
- * ` gid ` {integer}
215
- * Returns: {Promise}
212
+ * ` uid ` {integer} The file's new owner's user id.
213
+ * ` gid ` {integer} * ` gid ` {integer} The file's new group's group id.
214
+ * Returns: {Promise} Fulfills with ` undefined ` upon success.
216
215
217
- Changes the ownership of the file then resolves the promise with no arguments
218
- upon success.
216
+ Changes the ownership of the file. A wrapper for chown(2).
219
217
220
218
#### ` filehandle.close() `
221
219
<!-- YAML
222
220
added: v10.0.0
223
221
-->
224
222
225
- * Returns: {Promise}
223
+ * Returns: {Promise} Fulfills with ` undefined ` upon success.
226
224
227
225
Closes the file handle after waiting for any pending operation on the handle to
228
- complete. The promise is resolved with no arguments once complete.
226
+ complete.
229
227
230
228
``` js esm
231
229
import { open } from ' fs/promises' ;
@@ -243,13 +241,13 @@ try {
243
241
added: v10.0.0
244
242
-->
245
243
246
- * Returns: {Promise}
244
+ * Returns: {Promise} Fulfills with ` undefined ` upon success.
247
245
248
246
Forces all currently queued I/O operations associated with the file to the
249
247
operating system's synchronized I/O completion state. Refer to the POSIX
250
- fdatasync(2) documentation for details. The promise is resolved with no
251
- arguments upon success.
248
+ fdatasync(2) documentation for details.
252
249
250
+ Unlike ` filehandle .sync ` this method does not flush modified metadata.
253
251
#### ` filehandle .fd `
254
252
<!-- YAML
255
253
added: v10.0.0
@@ -271,16 +269,12 @@ added: v10.0.0
271
269
file. If ` null ` , data will be read from the current file position, and
272
270
the position will be updated. If ` position` is an integer, the current
273
271
file position will remain unchanged.
274
- * Returns: {Promise}
272
+ * Returns: {Promise} Fulfills upon success with an object with two properties:
273
+ * ` bytesRead` {integer} The number of bytes read
274
+ * ` buffer` {Buffer|Uint8Array} A reference to the passed in ` buffer` argument.
275
275
276
276
Reads data from the file and stores that in the given buffer.
277
277
278
- Following successful read, the promise is resolved with an object with
279
- two properties:
280
-
281
- * ` bytesRead` {integer} The number of bytes read
282
- * ` buffer` {Buffer|Uint8Array} A reference to the passed in ` buffer` argument.
283
-
284
278
If the file is not modified concurrently, the end-of-file is reached when the
285
279
number of bytes read is zero.
286
280
@@ -300,16 +294,13 @@ added:
300
294
file. If ` null ` , data will be read from the current file position, and
301
295
the position will be updated. If ` position` is an integer, the current
302
296
file position will remain unchanged. **Default:**: ` null `
303
- * Returns: {Promise}
297
+ * Returns: {Promise} Fulfills upon success with an object with two properties:
298
+ * ` bytesRead` {integer} The number of bytes read
299
+ * ` buffer` {Buffer|Uint8Array} A reference to the passed in ` buffer`
300
+ argument.
304
301
305
302
Reads data from the file and stores that in the given buffer.
306
303
307
- Following successful read, the promise is resolved with an object with
308
- two properties:
309
-
310
- * ` bytesRead` {integer} The number of bytes read
311
- * ` buffer` {Buffer|Uint8Array} A reference to the passed in ` buffer` argument.
312
-
313
304
If the file is not modified concurrently, the end-of-file is reached when the
314
305
number of bytes read is zero.
315
306
@@ -321,14 +312,12 @@ added: v10.0.0
321
312
* ` options` {Object|string}
322
313
* ` encoding` {string|null} **Default:** ` null `
323
314
* ` signal` {AbortSignal} allows aborting an in-progress readFile
324
- * Returns: {Promise}
315
+ * Returns: {Promise} Fulfills upon a successful read with the contents of the
316
+ file. If no encoding is specified (using ` options .encoding ` ), the data is
317
+ returned as a {Buffer} object. Otherwise, the data will be a string.
325
318
326
319
Asynchronously reads the entire contents of a file.
327
320
328
- The promise is resolved with the contents of the file. If no encoding is
329
- specified (using ` options .encoding ` ), the data is returned as a {Buffer}
330
- object. Otherwise, the data will be a string.
331
-
332
321
If ` options` is a string, then it specifies the ` encoding` .
333
322
334
323
The {FileHandle} has to support reading.
@@ -349,16 +338,13 @@ added:
349
338
* ` position` {integer} The offset from the beginning of the file where the data
350
339
should be read from. If ` position` is not a ` number` , the data will be read
351
340
from the current position.
352
- * Returns: {Promise}
341
+ * Returns: {Promise} Fulfills upon success an object containing two properties:
342
+ * ` bytesRead` {integer} the number of bytes read
343
+ * ` buffers` {Buffer[]|TypedArray[]|DataView[]} property containing
344
+ a reference to the ` buffers` input.
353
345
354
346
Read from a file and write to an array of {ArrayBufferView}s
355
347
356
- The promise is resolved with an object containing two properties:
357
-
358
- * ` bytesRead` {integer} the number of bytes read
359
- * ` buffers` {Buffer[]|TypedArray[]|DataView[]} property containing
360
- a reference to the ` buffers` input.
361
-
362
348
#### ` filehandle .stat ([options])`
363
349
<!-- YAML
364
350
added: v10.0.0
@@ -372,32 +358,30 @@ changes:
372
358
* ` options` {Object}
373
359
* ` bigint` {boolean} Whether the numeric values in the returned
374
360
{fs.Stats} object should be ` bigint` . **Default:** ` false ` .
375
- * Returns: {Promise}
361
+ * Returns: {Promise} Fulfills with an {fs.Stats} for the file.
362
+
376
363
377
- Resolves the promise with the {fs.Stats} for the file.
378
364
379
365
#### ` filehandle .sync ()`
380
366
<!-- YAML
381
367
added: v10.0.0
382
368
-->
383
369
384
- * Returns: {Promise}
370
+ * Returns: {Promise} Fufills with ` undefined ` upon success.
385
371
386
372
Request that all data for the open file descriptor is flushed to the storage
387
373
device. The specific implementation is operating system and device specific.
388
374
Refer to the POSIX fsync(2) documentation for more detail.
389
375
390
- The promise is resolved with no arguments upon success.
391
-
392
376
#### ` filehandle .truncate (len)`
393
377
<!-- YAML
394
378
added: v10.0.0
395
379
-->
396
380
397
381
* ` len` {integer} **Default:** ` 0 `
398
- * Returns: {Promise}
382
+ * Returns: {Promise} Fulfills with ` undefined ` upo nsuccess.
399
383
400
- Truncates the file then resolves the promise with no arguments upon success .
384
+ Truncates the file.
401
385
402
386
If the file was larger than ` len` bytes, only the first ` len` bytes will be
403
387
retained in the file.
@@ -2681,8 +2665,8 @@ changes:
2681
2665
* `offset` {integer} The position in `buffer` to write the data to.
2682
2666
* `length` {integer} The number of bytes to read.
2683
2667
* `position` {integer|bigint} Specifies where to begin reading from in the
2684
- file. If `position` is `null`, data will be read from the current file
2685
- position, and the file position will be updated. If `position` is an
2668
+ file. If `position` is `null` or `-1 ` , data will be read from the current
2669
+ file position, and the file position will be updated. If `position` is an
2686
2670
integer, the file position will be unchanged.
2687
2671
* `callback` {Function}
2688
2672
* `err` {Error}
@@ -4199,8 +4183,8 @@ added: v0.4.7
4199
4183
-->
4200
4184
4201
4185
* ` fd` {integer}
4202
- * ` uid` {integer}
4203
- * ` gid` {integer}
4186
+ * ` uid` {integer} The file's new owner's user id.
4187
+ * ` gid` {integer} * ` gid ` {integer} The file's new group's group id.
4204
4188
4205
4189
Sets the owner of the file. Returns ` undefined ` .
4206
4190
@@ -4302,8 +4286,8 @@ changes:
4302
4286
-->
4303
4287
4304
4288
* ` path` {string|Buffer|URL}
4305
- * ` uid` {integer}
4306
- * ` gid` {integer}
4289
+ * ` uid` {integer} The file's new owner's user id.
4290
+ * ` gid` {integer} * ` gid ` {integer} The file's new group's group id.
4307
4291
4308
4292
Set the owner for the path. Returns ` undefined ` .
4309
4293
0 commit comments