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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.10latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.10
0.1.00

Package Sidebar

Install

npm i callbacker

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • scottcorgan