Skip to content

Commit 17e80ec

Browse files
codebytereBridgeAR
authored andcommitted
src: prefer param function check over args length
PR-URL: #23835 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
1 parent 415fcde commit 17e80ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/fs.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ function open(path, flags, mode, callback) {
418418
callback = flags;
419419
flags = 'r';
420420
mode = 0o666;
421-
} else if (arguments.length === 3) {
421+
} else if (typeof mode === 'function') {
422422
callback = mode;
423423
mode = 0o666;
424424
}
@@ -811,7 +811,7 @@ function readdirSync(path, options) {
811811
}
812812

813813
function fstat(fd, options, callback) {
814-
if (arguments.length < 3) {
814+
if (typeof options === 'function') {
815815
callback = options;
816816
options = {};
817817
}
@@ -822,7 +822,7 @@ function fstat(fd, options, callback) {
822822
}
823823

824824
function lstat(path, options, callback) {
825-
if (arguments.length < 3) {
825+
if (typeof options === 'function') {
826826
callback = options;
827827
options = {};
828828
}
@@ -835,7 +835,7 @@ function lstat(path, options, callback) {
835835
}
836836

837837
function stat(path, options, callback) {
838-
if (arguments.length < 3) {
838+
if (typeof options === 'function') {
839839
callback = options;
840840
options = {};
841841
}

0 commit comments

Comments
 (0)