0.1.1 • Published 12 years ago
callbacker v0.1.1
callbacker
Parse the last argument in a function as the callback function
Install
npm install callbacker --saveUsage
var callbacker = require('callbacker');
function doSomething () {
var args = callbacker(arguments);
var arg1 = args.at(0);
args.callback();
}
doSomething('arg1', function () {
// Called back
});Methods
at(index)
Returns the argument at that index. Returns null if argument is the callback. Use args.callback to access the callback.
callback()
Returns the last item in the arguments array if it is a function. Assumes the "node-style" callback-as-last-argument structure.
Run Tests
npm install
npm test