popfun

pop array, if last element is function

npm install popfun
8 downloads in the last week
13 downloads in the last month

popfun - pop fun off

Build Status devDependency Status

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.

Usage

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 (err, msg) {
  console.log(msg)
})

API

popfun(args)

  • args Object to pop if last element is of type 'function'

Returns function or null.

Installation

npm

License

MIT License

npm loves you