summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Senkpiel <fishrock123@rocketmail.com>2019-10-09 12:10:06 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2019-10-09 15:05:40 -0700
commit7f22aaf62b30b84270373d74d6f0f3c2e9f88a48 (patch)
tree8c4e14d3949bd4b307b16318525c25eeadd77896
parent0ff4a558afeb0ec051041e8f1f9c45d876ae0530 (diff)
downloadandroid-node-v8-7f22aaf62b30b84270373d74d6f0f3c2e9f88a48.tar.gz
android-node-v8-7f22aaf62b30b84270373d74d6f0f3c2e9f88a48.tar.bz2
android-node-v8-7f22aaf62b30b84270373d74d6f0f3c2e9f88a48.zip
fs: remove options.encoding from Dir.read*()
This is unlikely to be necessary in any case, and causes much unwarrented complexity when implementing further optimizations. Refs: https://github.com/nodejs/node/pull/29893#discussion_r333179482 PR-URL: https://github.com/nodejs/node/pull/29908 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
-rw-r--r--doc/api/fs.md25
-rw-r--r--lib/internal/fs/dir.js12
2 files changed, 10 insertions, 27 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md
index a6736d127e..885272724d 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -351,13 +351,11 @@ added: REPLACEME
Synchronously close the directory's underlying resource handle.
Subsequent reads will result in errors.
-### dir.read([options])
+### dir.read()
<!-- YAML
added: REPLACEME
-->
-* `options` {Object}
- * `encoding` {string|null} **Default:** `'utf8'`
* Returns: {Promise} containing {fs.Dirent}
Asynchronously read the next directory entry via readdir(3) as an
@@ -369,13 +367,11 @@ is completed.
_Directory entries returned by this function are in no particular order as
provided by the operating system's underlying directory mechanisms._
-### dir.read([options, ]callback)
+### dir.read(callback)
<!-- YAML
added: REPLACEME
-->
-* `options` {Object}
- * `encoding` {string|null} **Default:** `'utf8'`
* `callback` {Function}
* `err` {Error}
* `dirent` {fs.Dirent}
@@ -385,25 +381,19 @@ Asynchronously read the next directory entry via readdir(3) as an
The `callback` will be called with a [Dirent][] after the read is completed.
-The `encoding` option sets the encoding of the `name` in the `dirent`.
-
_Directory entries returned by this function are in no particular order as
provided by the operating system's underlying directory mechanisms._
-### dir.readSync([options])
+### dir.readSync()
<!-- YAML
added: REPLACEME
-->
-* `options` {Object}
- * `encoding` {string|null} **Default:** `'utf8'`
* Returns: {fs.Dirent}
Synchronously read the next directory entry via readdir(3) as an
[`fs.Dirent`][].
-The `encoding` option sets the encoding of the `name` in the `dirent`.
-
_Directory entries returned by this function are in no particular order as
provided by the operating system's underlying directory mechanisms._
@@ -2658,8 +2648,7 @@ Creates an [`fs.Dir`][], which contains all further functions for reading from
and cleaning up the directory.
The `encoding` option sets the encoding for the `path` while opening the
-directory and subsequent read operations (unless otherwise overriden during
-reads from the directory).
+directory and subsequent read operations.
## fs.opendirSync(path[, options])
<!-- YAML
@@ -2677,8 +2666,7 @@ Creates an [`fs.Dir`][], which contains all further functions for reading from
and cleaning up the directory.
The `encoding` option sets the encoding for the `path` while opening the
-directory and subsequent read operations (unless otherwise overriden during
-reads from the directory).
+directory and subsequent read operations.
## fs.read(fd, buffer, offset, length, position, callback)
<!-- YAML
@@ -4835,8 +4823,7 @@ Creates an [`fs.Dir`][], which contains all further functions for reading from
and cleaning up the directory.
The `encoding` option sets the encoding for the `path` while opening the
-directory and subsequent read operations (unless otherwise overriden during
-reads from the directory).
+directory and subsequent read operations.
Example using async interation:
diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js
index c1a25f0de3..175c632fc7 100644
--- a/lib/internal/fs/dir.js
+++ b/lib/internal/fs/dir.js
@@ -48,18 +48,16 @@ class Dir {
return this[kDirPath];
}
- read(options, callback) {
+ read(callback) {
if (this[kDirClosed] === true) {
throw new ERR_DIR_CLOSED();
}
- callback = typeof options === 'function' ? options : callback;
if (callback === undefined) {
- return this[kDirReadPromisified](options);
+ return this[kDirReadPromisified]();
} else if (typeof callback !== 'function') {
throw new ERR_INVALID_CALLBACK(callback);
}
- options = getOptions(options, this[kDirOptions]);
const req = new FSReqCallback();
req.oncomplete = (err, result) => {
@@ -70,7 +68,7 @@ class Dir {
};
this[kDirHandle].read(
- options.encoding,
+ this[kDirOptions].encoding,
req
);
}
@@ -80,11 +78,9 @@ class Dir {
throw new ERR_DIR_CLOSED();
}
- options = getOptions(options, this[kDirOptions]);
-
const ctx = { path: this[kDirPath] };
const result = this[kDirHandle].read(
- options.encoding,
+ this[kDirOptions].encoding,
undefined,
ctx
);