From 7cf56797dddc7a00f76b6c9ffda7270c15f8c6d3 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 ef516a218c7..a717d794345 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -418,7 +418,7 @@ function open(path, flags, mode, callback) { callback = flags; flags = 'r'; mode = 0o666; - } else if (arguments.length === 3) { + } else if (typeof mode === 'function') { callback = mode; mode = 0o666; } @@ -811,7 +811,7 @@ function readdirSync(path, options) { } function fstat(fd, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; } @@ -822,7 +822,7 @@ function fstat(fd, options, callback) { } function lstat(path, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; } @@ -835,7 +835,7 @@ function lstat(path, options, callback) { } function stat(path, options, callback) { - if (arguments.length < 3) { + if (typeof options === 'function') { callback = options; options = {}; }