Skip to content

Commit

Permalink
doc: update fs promise-based examples
Browse files Browse the repository at this point in the history
#34843 was cherry-picked onto
`v12.x-staging` in 961844d but the `fs/promises` API, as used
in the examples, is only available from Node.js 14. Change the
added examples to use `require(fs).promises` instead.

PR-URL: #35760
Fixes: #35740
Refs: #34843
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
  • Loading branch information
richardlau authored and MylesBorins committed Nov 16, 2020
1 parent 0f757bc commit 68c5ee4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Promise-based operations return a `Promise` that is resolved when the
asynchronous operation is complete.

```js
const fs = require('fs/promises');
const fs = require('fs').promises;

(async function(path) {
try {
Expand Down Expand Up @@ -106,7 +106,7 @@ fs.rename('/tmp/hello', '/tmp/world', (err) => {
Or, use the promise-based API:

```js
const fs = require('fs/promises');
const fs = require('fs').promises;

(async function(from, to) {
try {
Expand Down

0 comments on commit 68c5ee4

Please sign in to comment.