From fbcb4f50b81cc57774998b2c3172626b6e4288be Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 16 Apr 2017 21:19:36 +0200 Subject: [PATCH] fs: support util.promisify for fs.read/fs.write PR-URL: https://github.com/nodejs/node/pull/12442 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Myles Borins Reviewed-By: Evan Lucas Reviewed-By: William Kapke Reviewed-By: Timothy Gu Reviewed-By: Teddy Katz --- doc/api/fs.md | 11 ++++++++-- lib/fs.js | 6 ++++++ test/parallel/test-fs-promisified.js | 31 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-fs-promisified.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 5b30579fff657c..16311dead4467b 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1612,6 +1612,9 @@ If `position` is `null`, data will be read from the current file position. The callback is given the three arguments, `(err, bytesRead, buffer)`. +If this method is invoked as its [`util.promisify()`][]ed version, it returns +a Promise for an object with `bytesRead` and `buffer` properties. + ## fs.readdir(path[, options], callback)