Function.thrower >= 0.1.4
Purpose
A function that will `throw` the first argument (if it is truthy)
Syntax
Function.thrower
(
Errorerr
);
Like `Function.dummy`, this can be used as a default callback parameter
Parameters
err
- Should be an Error, but can be anything
Examples
Use as callback
function myErrorFnc(callback) {
callback(new Error('There has been an error!'));
}
myErrorFnc(Function.thrower);>>> throws Error('There has been an error!')
function myNonErrorFnc(callback) {
callback(null);
}
myNonErrorFnc(Function.thrower);>>> throws nothing
Comments