get-callback.js
Get a callback function from arguments
{ var cb = ; console;} ; //yields: 'function cb(x, y) { return x + y; }'
This module is useful to create a function which takes a callback as its last argument.
Installation
Package managers
npm
npm install --save get-callback
bower
bower install --save get-callback
Standalone
Download the script file directly.
API
getCallback(args)
args: Array
or array-like object (e.g. arguments
)
Return: Function
It returns the last element of args, when the element is a function.
It throws an error when the last element is not a function.
{ //... Something to do in the callback} { ; //=> [Function: cb]}'foo' some: 'options' cb;
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT LIcense.