From 390db428537a5017aae2d5bf3b821bb9e622c708 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 ddb5b72b19e361..21f1b91db6e15e 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2547,14 +2547,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])