Skip to content

Commit a273da9

Browse files
codebytereMylesBorins
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 219040d commit a273da9

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
@@ -408,7 +408,7 @@ function open(path, flags, mode, callback) {
408408
path = toPathIfFileURL(path);
409409
validatePath(path);
410410
const flagsNumber = stringToFlags(flags);
411-
if (arguments.length < 4) {
411+
if (typeof mode === 'function') {
412412
callback = makeCallback(mode);
413413
mode = 0o666;
414414
} else {
@@ -788,7 +788,7 @@ function readdirSync(path, options) {
788788
}
789789

790790
function fstat(fd, options, callback) {
791-
if (arguments.length < 3) {
791+
if (typeof options === 'function') {
792792
callback = options;
793793
options = {};
794794
}
@@ -799,7 +799,7 @@ function fstat(fd, options, callback) {
799799
}
800800

801801
function lstat(path, options, callback) {
802-
if (arguments.length < 3) {
802+
if (typeof options === 'function') {
803803
callback = options;
804804
options = {};
805805
}
@@ -812,7 +812,7 @@ function lstat(path, options, callback) {
812812
}
813813

814814
function stat(path, options, callback) {
815-
if (arguments.length < 3) {
815+
if (typeof options === 'function') {
816816
callback = options;
817817
options = {};
818818
}

0 commit comments

Comments
 (0)