Skip to content

Commit ab297ce

Browse files
author
Anthony Nowell
committed
Fix #8: only invoke callback if it's a function
1 parent cde2edf commit ab297ce

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/algorithm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Algorithm = (function() {
2828
'Content-Type': contentType
2929
}, (function(_this) {
3030
return function(response, status) {
31-
return _this.callback(new AlgoResponse(response, status));
31+
return typeof _this.callback === "function" ? _this.callback(new AlgoResponse(response, status)) : void 0;
3232
};
3333
})(this));
3434
return this.promise;

src/algorithm.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Algorithm
2525
'POST',
2626
data,
2727
{'Content-Type': contentType},
28-
(response, status) => @callback(new AlgoResponse(response, status))
28+
(response, status) => @callback?(new AlgoResponse(response, status))
2929
)
3030

3131
@promise

0 commit comments

Comments
 (0)