From 8bd6df8927c1363789b195020397c8a672a46a0a Mon Sep 17 00:00:00 2001 From: "Sakthipriyan Vairamani (thefourtheye)" Date: Wed, 17 Oct 2018 12:56:13 +0530 Subject: [PATCH] doc: clarify fd behaviour with {read,write}File MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23706 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Vse Mozhet Byt Reviewed-By: Trivikram Kamat Reviewed-By: Matteo Collina Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Michael Dawson --- doc/api/fs.md | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 47fcefbac07b9b..9de798c6ff7ca2 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2554,14 +2554,18 @@ fs.readFile('', (err, data) => { }); ``` -Any specified file descriptor has to support reading. - -If a file descriptor is specified as the `path`, it will not be closed -automatically. - The `fs.readFile()` function buffers the entire file. To minimize memory costs, when possible prefer streaming via `fs.createReadStream()`. +### File Descriptors +1. Any specified file descriptor has to support reading. +2. If a file descriptor is specified as the `path`, it will not be closed +automatically. +3. The reading will begin at the current position. For example, if the file +already had `'Hello World`' and six bytes are read with the file descriptor, +the call to `fs.readFile()` with the same file descriptor, would give +`'World'`, rather than `'Hello World'`. + ## fs.readFileSync(path[, options])