Skip to content

Commit

Permalink
binding.readdir can take anywhere from 2 to 4 arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellgerber committed Sep 10, 2018
1 parent c1cdeec commit 38ca5db
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/binding.js
Expand Up @@ -692,14 +692,25 @@ Binding.prototype.rename = function(oldPath, newPath, callback) {
* Read a directory.
* @param {string} dirpath Path to directory.
* @param {string} encoding The encoding ('utf-8' or 'buffer').
* @param {boolean} withFileTypes whether or not to return fs.Dirent objects
* @param {function(Error, (Array.<string>|Array.<Buffer>)} callback Callback
* (optional) called with any error or array of items in the directory.
* @return {Array.<string>|Array.<Buffer>} Array of items in directory (if sync).
*/
Binding.prototype.readdir = function(dirpath, encoding, callback) {
if (encoding && typeof encoding !== 'string') {
Binding.prototype.readdir = function(
dirpath,
encoding,
withFileTypes,
callback
) {
if (arguments.length === 2) {
callback = encoding;
encoding = 'utf-8';
} else if (arguments.length === 3) {
callback = withFileTypes;
}
if (withFileTypes === true) {
notImplemented();
}
return maybeCallback(normalizeCallback(callback), this, function() {
var dpath = dirpath;
Expand Down

0 comments on commit 38ca5db

Please sign in to comment.