From 38ca5db94ff14ffc5c376fb40bbbf7363e357f2c Mon Sep 17 00:00:00 2001 From: Maxwell Gerber Date: Mon, 10 Sep 2018 12:50:11 -0700 Subject: [PATCH] binding.readdir can take anywhere from 2 to 4 arguments --- lib/binding.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/binding.js b/lib/binding.js index ae8eafc7..89c76cba 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -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.|Array.)} callback Callback * (optional) called with any error or array of items in the directory. * @return {Array.|Array.} 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;