Depromise
It hurts when callbacks executed inside promises throw errors. To avoid the hurt, use a Promise library such as bluebird that provides a .done
method.
depromise
provides a helper function success
that takes a callback function of any arity and returns a function that will call the callback with the proper arguments.
Usage
var depromise = ;
The usual callback pattern
{ var onFailure = next; var onSuccess = depromise; } ;
Callbacks with multiple arguments
Call depromise.success
with the optional HAS_MULTIPLE_ARGS flag (true
) and return an array containing the arguments for the callback.
{ var onFailure = next; var onSuccess = depromise; } ;