Skip to content

Commit

Permalink
Merge pull request #251 from maxwellgerber/fix/dirent-patch
Browse files Browse the repository at this point in the history
binding.readdir can take anywhere from 2 to 4 arguments
  • Loading branch information
tschaub authored Sep 11, 2018
2 parents 28d65a7 + 38ca5db commit b81c39b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,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 b81c39b

Please sign in to comment.