Newton's Preposterous Miscalculation
Have ideas to improve npm?Join in the discussion! »

callbacker

0.1.1 • Public • Published

callbacker

Parse the last argument in a function as the callback function

Install

npm install callbacker --save

Usage

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

Install

npm i callbacker

DownloadsWeekly Downloads

7

Version

0.1.1

License

MIT

Last publish

Collaborators

  • avatar