0.1.1 • Published 10 years ago

callbacker v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

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
0.1.1

10 years ago

0.1.0

10 years ago