From 96ac7427f58545302a9b57dbd4d67eed6a15135f Mon Sep 17 00:00:00 2001 From: Asriel Yu Date: Wed, 10 Sep 2025 22:34:44 +0800 Subject: [PATCH] doc: add missing api fs cjs code snippet There's non toggle button at every piece of code in file system doc. This would be of no use if the developer has not imported the fs module in every piece of code just like in any other docs. Fixes: https://github.com/nodejs/node/issues/59769 Refs: https://nodejs.org/docs/latest/api/fs.html --- doc/api/fs.md | 977 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 966 insertions(+), 11 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index c0c88a3abb90c1..2eb4739ed5084e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -253,6 +253,19 @@ try { } ``` +```cjs +const { open } = require('node:fs/promises'); + +(async () => { + let filehandle; + try { + filehandle = await open('thefile.txt', 'r'); + } finally { + await filehandle?.close(); + } +})(); +``` + #### `filehandle.createReadStream([options])`