Skip to content

Commit 3579a9d

Browse files
committed
Minor code restructuring on fs.stat options
1 parent 2284a19 commit 3579a9d

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

polyfills.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ function patch (fs) {
272272
}
273273
}
274274

275-
276275
function statFix (orig) {
277276
if (!orig) return orig
278277
// Older versions of Node erroneously returned signed integers for
@@ -282,16 +281,15 @@ function patch (fs) {
282281
cb = options
283282
options = null
284283
}
285-
function callback(err, stats) {
286-
if (!stats && cb) return cb.apply(this, arguments)
287-
if (stats.uid < 0) stats.uid += 0x100000000
288-
if (stats.gid < 0) stats.gid += 0x100000000
284+
function callback (er, stats) {
285+
if (stats) {
286+
if (stats.uid < 0) stats.uid += 0x100000000
287+
if (stats.gid < 0) stats.gid += 0x100000000
288+
}
289289
if (cb) cb.apply(this, arguments)
290290
}
291-
if (options) {
292-
return orig.call(fs, target, options, callback);
293-
}
294-
return orig.call(fs, target, callback);
291+
return options ? orig.call(fs, target, options, callback)
292+
: orig.call(fs, target, callback)
295293
}
296294
}
297295

@@ -300,12 +298,8 @@ function patch (fs) {
300298
// Older versions of Node erroneously returned signed integers for
301299
// uid + gid.
302300
return function (target, options) {
303-
var stats
304-
if (options) {
305-
stats = orig.call(fs, target, options)
306-
} else {
307-
stats = orig.call(fs, target)
308-
}
301+
var stats = options ? orig.call(fs, target, options)
302+
: orig.call(fs, target)
309303
if (stats.uid < 0) stats.uid += 0x100000000
310304
if (stats.gid < 0) stats.gid += 0x100000000
311305
return stats;

0 commit comments

Comments
 (0)