Skip to content

Commit cc8bff5

Browse files
per2plexphated
authored andcommitted
Fix: Handle non-functions passed as callback
1 parent b6b06be commit cc8bff5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/helpers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function getExtensions(lastArg) {
1111
}
1212

1313
function buildOnSettled(done) {
14-
done = done || _.noop;
14+
if (typeof done !== 'function') {
15+
done = _.noop;
16+
}
1517

1618
function onSettled(error, result) {
1719
if (error) {

test/onSettled.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ describe('onSettled', function() {
3434
onSettled()(null, errors);
3535
done();
3636
});
37+
38+
it('should handle non-functions as callbacks', function(done) {
39+
onSettled('not a function')(null, errors);
40+
done();
41+
});
3742
});

0 commit comments

Comments
 (0)