From 58e9ccaaa56cd36ec4ed2bb34a1143dbc2ff08cd Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 6 Nov 2018 11:17:26 -0800 Subject: [PATCH] src: prefer param function check over args length PR-URL: https://github.com/nodejs/node/pull/23835 Reviewed-By: Refael Ackermann Reviewed-By: Matheus Marchini Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: John-David Dalton Reviewed-By: Yuta Hiroto --- lib/fs.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 56421924fd287a..8d2c1dca628a2b 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -408,7 +408,7 @@ function open(path, flags, mode, callback) { path = toPathIfFileURL(path); validatePath(path); const flagsNumber = stringToFlags(flags); - if (arguments.length < 4) { + if (typeof mode === 'function') { callback = makeCallback(mode); mode = 0o666; } else { @@ -788,7 +788,7 @@ function readdirSync(path, options) { } function fstat(fd, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; } @@ -799,7 +799,7 @@ function fstat(fd, options, callback) { } function lstat(path, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; } @@ -812,7 +812,7 @@ function lstat(path, options, callback) { } function stat(path, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; }