popfun

pop array, if last element is function

popfun - pop fun off

The popfun node module removes the last element from an array and returns that value to the caller, if the element is of type 'function'; for example, the callback in an arguments array.

var popfun = require('popfun')
 
function echo () {
  var args = Array.prototype.slice.call(arguments)
    , callback = popfun(args)
  
  if (callback) callback(null, args.join(' '))
}
 
echo('hey', 'you', function (errmsg) {
  console.log(msg)
})
  • args Object to pop if last element is of type 'function'

Returns function or null.

MIT License