Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

listen

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listen - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

autolint.js

15

lib/listen.js

@@ -12,8 +12,9 @@ /**

function listen(values) {
function listen(initialValues) {
var values;
if (arguments.length) {
if (Object.prototype.toString.call(values) !== '[object Array]') {
if (Object.prototype.toString.call(initialValues) !== '[object Array]') {
throw new TypeError('Array expected');
}
values = Array.prototype.slice.call(values);
values = Array.prototype.slice.call(initialValues);
} else {

@@ -47,3 +48,7 @@ values = [];

}
errList.push(e);
if (e.name === 'ErrorList') {
Array.prototype.push.apply(errList, e.errors);
} else {
errList.push(e);
}
}

@@ -65,3 +70,3 @@

};
};
}

@@ -68,0 +73,0 @@ listener.push = function push(value) {

{
"name" : "listen",
"version" : "0.1.3",
"version" : "0.1.4",
"description" : "Wait for the results of multiple callbacks",

@@ -21,4 +21,5 @@ "author" : "Maximilian Antoni (http://maxantoni.de)",

"urun" : "~0.0.6",
"sinon" : "~1.3.4",
"uglify-js" : "~1.2.6"
"sinon" : "~1.4.2",
"uglify-js" : "~1.2.6",
"autolint" : "~1.0.4"
},

@@ -25,0 +26,0 @@ "nomo" : {

@@ -15,2 +15,3 @@ /**

var listen = require('../lib/listen');
var ErrorList = require('../lib/error-list');

@@ -32,13 +33,33 @@

assert.deepEqual(spy.firstCall.args[0].errors, ['a', 'b']);
sinon.assert.calledWithMatch(spy, {
errors : ['a', 'b']
});
},
'should add error-list to error-list for then-callback': function () {
var spy = sinon.spy();
this.listener.err('a');
this.listener.err(new ErrorList(['b', 'c']));
this.listener.then(spy);
sinon.assert.calledWithMatch(spy, {
errors : ['a', 'b', 'c']
});
},
'should throw if called after then': function () {
this.listener.then(function () {});
var self = this;
var error;
assert.throws(function () {
self.listener.err();
}, /^Error: Cannot be called after then$/);
try {
this.listener.err();
} catch (e) {
error = e;
}
assert.equal("Error", error.name);
assert.equal("Cannot be called after then", error.message);
}

@@ -45,0 +66,0 @@

@@ -32,7 +32,12 @@ /**

this.listener.then(function () {});
var self = this;
var error;
assert.throws(function () {
self.listener();
}, /^Error: Cannot be called after then$/);
try {
this.listener();
} catch (e) {
error = e;
}
assert.equal('Error', error.name);
assert.equal('Cannot be called after then', error.message);
}

@@ -39,0 +44,0 @@

@@ -49,7 +49,12 @@ /**

this.listener.then(function () {});
var self = this;
var error;
assert.throws(function () {
self.listener.push(1);
}, /^Error: Cannot be called after then$/);
try {
this.listener.push(1);
} catch (e) {
error = e;
}
assert.equal('Error', error.name);
assert.equal('Cannot be called after then', error.message);
}

@@ -56,0 +61,0 @@

@@ -204,8 +204,14 @@ /**

'should throw if called again': function () {
var then= this.then;
var then = this.then;
var error;
then(function () {});
assert.throws(function () {
try {
then(function () {});
}, /^Error: Cannot be called more than once$/);
} catch (e) {
error = e;
}
assert.equal('Error', error.name);
assert.equal('Cannot be called more than once', error.message);
}

@@ -212,0 +218,0 @@

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