Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 3a37851

Browse files
committed
improved makeCallback arg checking
1 parent b510fbd commit 3a37851

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/fs.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ function maybeCallback(cb) {
9191
// for callbacks that are passed to the binding layer, callbacks that are
9292
// invoked from JS already run in the proper scope.
9393
function makeCallback(cb) {
94-
if (!util.isFunction(cb)) {
94+
if (util.ifNullOrUndefined(cb)) {
9595
return rethrow();
9696
}
97+
if (!util.isFunction(cb)) {
98+
throw new Error('callback must be a function');
99+
}
97100

98101
return function() {
99102
return cb.apply(null, arguments);

0 commit comments

Comments
 (0)