mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
fs: add fs/promises alias module
PR-URL: https://github.com/nodejs/node/pull/31553 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
This commit is contained in:
parent
e6c2277241
commit
b8e41774d4
@ -4237,7 +4237,7 @@ this API: [`fs.writev()`][].
|
||||
|
||||
The `fs.promises` API provides an alternative set of asynchronous file system
|
||||
methods that return `Promise` objects rather than using callbacks. The
|
||||
API is accessible via `require('fs').promises`.
|
||||
API is accessible via `require('fs').promises` or `require('fs/promises')`.
|
||||
|
||||
### class: `FileHandle`
|
||||
<!-- YAML
|
||||
|
3
lib/fs/promises.js
Normal file
3
lib/fs/promises.js
Normal file
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('internal/fs/promises').exports;
|
1
node.gyp
1
node.gyp
@ -51,6 +51,7 @@
|
||||
'lib/domain.js',
|
||||
'lib/events.js',
|
||||
'lib/fs.js',
|
||||
'lib/fs/promises.js',
|
||||
'lib/http.js',
|
||||
'lib/http2.js',
|
||||
'lib/_http_agent.js',
|
||||
|
5
test/es-module/test-esm-fs-promises.mjs
Normal file
5
test/es-module/test-esm-fs-promises.mjs
Normal file
@ -0,0 +1,5 @@
|
||||
import '../common/index.mjs';
|
||||
import { stat } from 'fs/promises';
|
||||
|
||||
// Should not reject.
|
||||
stat(new URL(import.meta.url));
|
6
test/parallel/test-fs-promises-exists.js
Normal file
6
test/parallel/test-fs-promises-exists.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
assert.strictEqual(require('fs/promises'), require('fs').promises);
|
Loading…
Reference in New Issue
Block a user