Skip to content

Commit

Permalink
Fix: Handle non-functions passed as callback
Browse files Browse the repository at this point in the history
  • Loading branch information
per2plex authored and phated committed Jun 27, 2016
1 parent b6b06be commit cc8bff5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function getExtensions(lastArg) {
}

function buildOnSettled(done) {
done = done || _.noop;
if (typeof done !== 'function') {
done = _.noop;
}

function onSettled(error, result) {
if (error) {
Expand Down
5 changes: 5 additions & 0 deletions test/onSettled.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ describe('onSettled', function() {
onSettled()(null, errors);
done();
});

it('should handle non-functions as callbacks', function(done) {
onSettled('not a function')(null, errors);
done();
});
});

0 comments on commit cc8bff5

Please sign in to comment.