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:
Gus Caplan 2020-01-28 08:29:29 -08:00
parent e6c2277241
commit b8e41774d4
No known key found for this signature in database
GPG Key ID: F00BD11880E82F0E
5 changed files with 16 additions and 1 deletions

View File

@ -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
View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('internal/fs/promises').exports;

View File

@ -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',

View File

@ -0,0 +1,5 @@
import '../common/index.mjs';
import { stat } from 'fs/promises';
// Should not reject.
stat(new URL(import.meta.url));

View File

@ -0,0 +1,6 @@
'use strict';
require('../common');
const assert = require('assert');
assert.strictEqual(require('fs/promises'), require('fs').promises);