Comparing version 0.3.0 to 0.3.1
@@ -34,2 +34,9 @@ /** | ||
} else { | ||
while (offset < values.length - 1) { | ||
if (values[offset] !== undefined) { | ||
offset++; | ||
} else { | ||
values.splice(offset, 1); | ||
} | ||
} | ||
fn(null, values); | ||
@@ -70,2 +77,3 @@ } | ||
function listener(fn, timeout) { | ||
assertUnresolved(); | ||
if (typeof fn === 'number') { | ||
@@ -75,4 +83,3 @@ timeout = fn; | ||
} | ||
assertUnresolved(); | ||
var index = offset + count++; | ||
var index = offset + count++; | ||
var callback = function (err, value) { | ||
@@ -79,0 +86,0 @@ if (fn) { |
{ | ||
"name" : "listen", | ||
"version" : "0.3.0", | ||
"version" : "0.3.1", | ||
"description" : "Wait for the results of multiple callbacks", | ||
@@ -21,3 +21,3 @@ "author" : "Maximilian Antoni (http://maxantoni.de)", | ||
"urun" : "~0.0.6", | ||
"sinon" : "~1.5.0", | ||
"sinon" : "~1.6.0", | ||
"uglify-js" : "~1.2.6", | ||
@@ -24,0 +24,0 @@ "autolint" : "~1.0.4" |
# listen.js | ||
Wait for the results of multiple callbacks. | ||
Wait for the results of multiple callbacks | ||
Repository: https://github.com/mantoni/listen.js | ||
[![Build Status](https://secure.travis-ci.org/mantoni/listen.js.png?branch=master)](http://travis-ci.org/mantoni/listen.js) | ||
## Install | ||
## Install on Node | ||
@@ -76,6 +78,7 @@ ``` | ||
## Hacking | ||
## Contrubuting | ||
If you'd like to hack listen.js here is how to get started: | ||
If you'd like to contribute to listen.js here is how to get started: | ||
- Fork the project on GitHub. | ||
- `npm install` will setup everything you need. | ||
@@ -82,0 +85,0 @@ - `make` lints the code with JSLint and runs all unit tests. |
@@ -116,3 +116,3 @@ /** | ||
this.then(spy); | ||
callback(); | ||
callback(); // undefined value is ignored. | ||
@@ -175,2 +175,47 @@ sinon.assert.calledWith(spy, null, []); | ||
'should not pass undefined from first value': function () { | ||
var spy = sinon.spy(); | ||
var callbackA = this.listener(); | ||
var callbackB = this.listener(); | ||
var callbackC = this.listener(); | ||
callbackA(); | ||
callbackB(null, 'B'); | ||
callbackC(null, 'C'); | ||
this.then(spy); | ||
sinon.assert.calledWith(spy, null, ['B', 'C']); | ||
}, | ||
'should not pass undefined from second value': function () { | ||
var spy = sinon.spy(); | ||
var callbackA = this.listener(); | ||
var callbackB = this.listener(); | ||
var callbackC = this.listener(); | ||
callbackA(null, 'A'); | ||
callbackB(); | ||
callbackC(null, 'C'); | ||
this.then(spy); | ||
sinon.assert.calledWith(spy, null, ['A', 'C']); | ||
}, | ||
'should not pass undefined from third value': function () { | ||
var spy = sinon.spy(); | ||
var callbackA = this.listener(); | ||
var callbackB = this.listener(); | ||
var callbackC = this.listener(); | ||
callbackA(null, 'A'); | ||
callbackB(null, 'B'); | ||
callbackC(); | ||
this.then(spy); | ||
sinon.assert.calledWith(spy, null, ['A', 'B']); | ||
}, | ||
'should pass error to given function': function () { | ||
@@ -177,0 +222,0 @@ var spy = sinon.spy(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
29102
697
94