Comparing version 0.1.2 to 1.0.0
@@ -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 | ||
[](http://travis-ci.org/michaelnisi/popfun) [](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. | ||
[](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 | ||
[](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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4242
8
45
1
42
0