New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

popfun

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popfun - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

.npmignore

6

example/callback.js

@@ -5,9 +5,9 @@ var popfun = require('popfun')

var args = Array.prototype.slice.call(arguments)
, callback = popfun(args)
var callback = popfun(args)
if (callback) callback(null, args.join(' '))
}
echo('hey', 'you', function (err, msg) {
echo('hey', 'you', function (er, msg) {
if (er) throw er
console.log(msg)
})
{
"name": "popfun",
"version": "0.1.2",
"version": "1.0.0",
"description": "pop array, if last element is function",

@@ -13,3 +13,3 @@ "main": "index.js",

"devDependencies": {
"tap": "0.4.x"
"tap": "^1.4.0"
},

@@ -21,4 +21,3 @@ "repository": {

"engines": {
"node": "0.11.x"
, "node": "0.10.x"
"node": ">0.10"
},

@@ -25,0 +24,0 @@ "keywords": [

@@ -1,8 +0,9 @@

# popfun - pop fun off
# popfun - pop function
[![Build Status](https://secure.travis-ci.org/michaelnisi/popfun.png)](http://travis-ci.org/michaelnisi/popfun) [![devDependency Status](https://david-dm.org/michaelnisi/popfun/dev-status.png)](https://david-dm.org/michaelnisi/popfun#info=devDependencies)
The **popfun** [Node.js](http://nodejs.org/) 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]`).
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.
[![Build Status](https://secure.travis-ci.org/michaelnisi/popfun.png)](http://travis-ci.org/michaelnisi/popfun)
## Usage
## Example
```js

@@ -13,4 +14,3 @@ var popfun = require('popfun')

var args = Array.prototype.slice.call(arguments)
, callback = popfun(args)
var callback = popfun(args)
if (callback) callback(null, args.join(' '))

@@ -23,4 +23,5 @@ }

```
## API
## Exports
### popfun(args)

@@ -30,10 +31,14 @@

Returns function or null.
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
[![npm](https://nodei.co/npm/popfun.png?compact=true)](https://npmjs.org/package/popfun)
With [npm](https://npmjs.org/package/popfun) do:
```
npm install popfun
```
## License
[MIT License](https://raw.github.com/michaelnisi/popfun/master/LICENSE)
var test = require('tap').test
, popfun = require('../index.js')
, callback = function () {}
var popfun = require('../index.js')
var callback = function () {}
test('argument', function (t) {

@@ -27,4 +28,4 @@ t.is(popfun(), null, 'should be null')

t.is(popfun(args), callback, 'should be callback')
t.is(args.length, 6, 'should be popped')
t.is(args.length, 6, 'should be popped')
t.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc