@@ -291,7 +291,8 @@ added: v12.12.0
291
291
292
292
A class representing a directory stream.
293
293
294
- Created by [ ` fs.opendir() ` ] [ ] , [ ` fs.opendirSync() ` ] [ ] , or [ ` fsPromises.opendir() ` ] [ ] .
294
+ Created by [ ` fs.opendir() ` ] [ ] , [ ` fs.opendirSync() ` ] [ ] , or
295
+ [ ` fsPromises.opendir() ` ] [ ] .
295
296
296
297
``` js
297
298
const fs = require (' fs' );
@@ -305,16 +306,6 @@ async function print(path) {
305
306
print (' ./' ).catch (console .error );
306
307
```
307
308
308
- ### dir.path
309
- <!-- YAML
310
- added: v12.12.0
311
- -->
312
-
313
- * {string}
314
-
315
- The read-only path of this directory as was provided to [ ` fs.opendir() ` ] [ ] ,
316
- [ ` fs.opendirSync() ` ] [ ] , or [ ` fsPromises.opendir() ` ] [ ] .
317
-
318
309
### dir.close()
319
310
<!-- YAML
320
311
added: v12.12.0
@@ -349,6 +340,16 @@ added: v12.12.0
349
340
Synchronously close the directory's underlying resource handle.
350
341
Subsequent reads will result in errors.
351
342
343
+ ### dir.path
344
+ <!-- YAML
345
+ added: v12.12.0
346
+ -->
347
+
348
+ * {string}
349
+
350
+ The read-only path of this directory as was provided to [ ` fs.opendir() ` ] [ ] ,
351
+ [ ` fs.opendirSync() ` ] [ ] , or [ ` fsPromises.opendir() ` ] [ ] .
352
+
352
353
### dir.read()
353
354
<!-- YAML
354
355
added: v12.12.0
@@ -429,7 +430,8 @@ included in the iteration results.
429
430
added: v10.10.0
430
431
-->
431
432
432
- A representation of a directory entry, as returned by reading from an [ ` fs.Dir ` ] [ ] .
433
+ A representation of a directory entry, as returned by reading from an
434
+ [ ` fs.Dir ` ] [ ] .
433
435
434
436
Additionally, when [ ` fs.readdir() ` ] [ ] or [ ` fs.readdirSync() ` ] [ ] is called with
435
437
the ` withFileTypes ` option set to ` true ` , the resulting array is filled with
@@ -2620,33 +2622,6 @@ a colon, Node.js will open a file system stream, as described by
2620
2622
Functions based on ` fs.open() ` exhibit this behavior as well:
2621
2623
` fs.writeFile() ` , ` fs.readFile() ` , etc.
2622
2624
2623
- ## fs.openSync(path\[ , flags, mode\] )
2624
- <!-- YAML
2625
- added: v0.1.21
2626
- changes:
2627
- - version: v11.1.0
2628
- pr-url: https://github.com/nodejs/node/pull/23767
2629
- description: The `flags` argument is now optional and defaults to `'r'`.
2630
- - version: v9.9.0
2631
- pr-url: https://github.com/nodejs/node/pull/18801
2632
- description: The `as` and `as+` modes are supported now.
2633
- - version: v7.6.0
2634
- pr-url: https://github.com/nodejs/node/pull/10739
2635
- description: The `path` parameter can be a WHATWG `URL` object using `file:`
2636
- protocol. Support is currently still *experimental*.
2637
- -->
2638
-
2639
- * ` path ` {string|Buffer|URL}
2640
- * ` flags ` {string|number} ** Default:** ` 'r' ` .
2641
- See [ support of file system ` flags ` ] [ ] .
2642
- * ` mode ` {integer} ** Default:** ` 0o666 `
2643
- * Returns: {number}
2644
-
2645
- Returns an integer representing the file descriptor.
2646
-
2647
- For detailed information, see the documentation of the asynchronous version of
2648
- this API: [ ` fs.open() ` ] [ ] .
2649
-
2650
2625
## fs.opendir(path\[ , options\] , callback)
2651
2626
<!-- YAML
2652
2627
added: v12.12.0
@@ -2685,6 +2660,33 @@ and cleaning up the directory.
2685
2660
The ` encoding ` option sets the encoding for the ` path ` while opening the
2686
2661
directory and subsequent read operations.
2687
2662
2663
+ ## fs.openSync(path\[ , flags, mode\] )
2664
+ <!-- YAML
2665
+ added: v0.1.21
2666
+ changes:
2667
+ - version: v11.1.0
2668
+ pr-url: https://github.com/nodejs/node/pull/23767
2669
+ description: The `flags` argument is now optional and defaults to `'r'`.
2670
+ - version: v9.9.0
2671
+ pr-url: https://github.com/nodejs/node/pull/18801
2672
+ description: The `as` and `as+` modes are supported now.
2673
+ - version: v7.6.0
2674
+ pr-url: https://github.com/nodejs/node/pull/10739
2675
+ description: The `path` parameter can be a WHATWG `URL` object using `file:`
2676
+ protocol. Support is currently still *experimental*.
2677
+ -->
2678
+
2679
+ * ` path ` {string|Buffer|URL}
2680
+ * ` flags ` {string|number} ** Default:** ` 'r' ` .
2681
+ See [ support of file system ` flags ` ] [ ] .
2682
+ * ` mode ` {integer} ** Default:** ` 0o666 `
2683
+ * Returns: {number}
2684
+
2685
+ Returns an integer representing the file descriptor.
2686
+
2687
+ For detailed information, see the documentation of the asynchronous version of
2688
+ this API: [ ` fs.open() ` ] [ ] .
2689
+
2688
2690
## fs.read(fd, buffer, offset, length, position, callback)
2689
2691
<!-- YAML
2690
2692
added: v0.0.2
@@ -4824,7 +4826,7 @@ by [Naming Files, Paths, and Namespaces][]. Under NTFS, if the filename contains
4824
4826
a colon, Node.js will open a file system stream, as described by
4825
4827
[ this MSDN page] [ MSDN-Using-Streams ] .
4826
4828
4827
- ## fsPromises.opendir(path\[ , options\] )
4829
+ ### fsPromises.opendir(path\[ , options\] )
4828
4830
<!-- YAML
4829
4831
added: v12.12.0
4830
4832
-->
@@ -5459,6 +5461,7 @@ the file contents.
5459
5461
[ `Buffer.byteLength` ] : buffer.html#buffer_class_method_buffer_bytelength_string_encoding
5460
5462
[ `Buffer` ] : buffer.html#buffer_buffer
5461
5463
[ `FSEvents` ] : https://developer.apple.com/documentation/coreservices/file_system_events
5464
+ [ `Number.MAX_SAFE_INTEGER` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
5462
5465
[ `ReadDirectoryChangesW` ] : https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
5463
5466
[ `ReadStream` ] : #fs_class_fs_readstream
5464
5467
[ `URL` ] : url.html#url_the_whatwg_url_api
@@ -5505,7 +5508,6 @@ the file contents.
5505
5508
[ `net.Socket` ] : net.html#net_class_net_socket
5506
5509
[ `stat()` ] : fs.html#fs_fs_stat_path_options_callback
5507
5510
[ `util.promisify()` ] : util.html#util_util_promisify_original
5508
- [ bigints ] : https://tc39.github.io/proposal-bigint
5509
5511
[ Caveats ] : #fs_caveats
5510
5512
[ Common System Errors ] : errors.html#errors_common_system_errors
5511
5513
[ FS Constants ] : #fs_fs_constants_1
@@ -5515,7 +5517,7 @@ the file contents.
5515
5517
[ MSDN-Rel-Path ] : https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths
5516
5518
[ MSDN-Using-Streams ] : https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams
5517
5519
[ Naming Files, Paths, and Namespaces ] : https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file
5520
+ [ bigints ] : https://tc39.github.io/proposal-bigint
5518
5521
[ chcp ] : https://ss64.com/nt/chcp.html
5519
5522
[ inode ] : https://en.wikipedia.org/wiki/Inode
5520
5523
[ support of file system `flags` ] : #fs_file_system_flags
5521
- [ `Number.MAX_SAFE_INTEGER` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
0 commit comments