Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    popfunpublic

    popfun - pop function

    The popfun Node.js module removes the last element from an array if it is a function and returns it. This can be handy to fetch the callback from an arguments array ([err, a1, a2, an, cb]).

    Build Status

    Example

    var popfun = require('popfun')
     
    function echo () {
      var args = Array.prototype.slice.call(arguments)
      var callback = popfun(args)
      if (callback) callback(null, args.join(' '))
    }
     
    echo('hey', 'you', function (err, msg) {
      console.log(msg)
    })

    Exports

    popfun(args)

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

    This function can take any type. If it receives an array, it pops the last element, and returns the element; else it returns null.

    Installation

    With npm do:

    npm install popfun
    

    License

    MIT License

    install

    npm i popfun

    Downloadsweekly downloads

    7

    version

    1.0.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar