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

Commit

Permalink
improved makeCallback arg checking
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Feb 14, 2015
1 parent b510fbd commit 3a37851
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ function maybeCallback(cb) {
// for callbacks that are passed to the binding layer, callbacks that are
// invoked from JS already run in the proper scope.
function makeCallback(cb) {
if (!util.isFunction(cb)) {
if (util.ifNullOrUndefined(cb)) {
return rethrow();
}
if (!util.isFunction(cb)) {
throw new Error('callback must be a function');
}

return function() {
return cb.apply(null, arguments);
Expand Down

0 comments on commit 3a37851

Please sign in to comment.