You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

raptor-async

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raptor-async - npm Package Compare versions

Comparing version

to
1.1.3

6

package.json

@@ -15,4 +15,4 @@ {

"devDependencies": {
"mocha": "~1.15.1",
"chai": "~1.8.1"
"chai": "^3.5.0",
"mocha": "^2.5.1"
},

@@ -25,3 +25,3 @@ "license": "Apache License v2.0",

},
"version": "1.1.2"
"version": "1.1.3"
}
module.exports = function parallel(work, callback, thisObj) {
var results;

@@ -25,3 +25,3 @@ var len;

if (invoked === true) {
throw new Error('callback for async operation with key "' + key + '" invoked more than once');
throw new Error('callback for async operation with key "' + key + '" invoked after completion. ' + (err ? (err.stack || err) : '(no error)'));
}

@@ -32,3 +32,3 @@

results[key] = data;
if (err) {

@@ -78,2 +78,2 @@ done(err);

}
};
};
module.exports = function series(work, callback, thisObj) {
var results = new Array(work.length);

@@ -14,4 +14,5 @@

return function(err, data) {
if (invoked === true) {
throw new Error('callback for async operation at index ' + index + ' invoked more than once');
throw new Error('callback for async operation at index "' + index + '" invoked after completion. ' + (err ? (err.stack || err) : '(no error)'));
}

@@ -41,2 +42,2 @@

work[0].call(thisObj, createCallback(0));
};
};
'use strict';
require('chai').should();
require('chai').Assertion.includeStack = true;
require('chai').config.includeStack = true;
var expect = require('chai').expect;

@@ -6,0 +6,0 @@

'use strict';
require('chai').should();
require('chai').Assertion.includeStack = true;
require('chai').config.includeStack = true;
var expect = require('chai').expect;

@@ -6,0 +6,0 @@ var Domain = require('domain');

@@ -33,3 +33,3 @@ 'use strict';

it('should return array results in correct order', function(done) {
this.timeout(2000);

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

it('should return mapped results', function(done) {
this.timeout(2000);

@@ -97,3 +97,3 @@

it('should throw error if callback for job is invoked more than once', function(done) {
var uncaughtException;

@@ -136,6 +136,50 @@

expect(results).to.deep.equal({a: 0, b: 1, c: 2});
expect(uncaughtException.toString()).to.equal('Error: callback for async operation with key "b" invoked more than once');
expect(uncaughtException.toString()).to.equal('Error: callback for async operation with key \"b\" invoked after completion. (no error)');
done();
});
});
it('should include original error if callback is invoked after completion', function(done) {
var uncaughtException;
var mochaExceptionHandler = process.listeners('uncaughtException').pop();
process.removeListener('uncaughtException', mochaExceptionHandler);
process.once('uncaughtException', function(err) {
// errors for invoking callback more than once will be thrown as errors
// since they fall into the unexpected exception category
uncaughtException = err;
process.on('uncaughtException', mochaExceptionHandler);
});
this.timeout(2000);
var work = {};
work.a = function(callback) {
setTimeout(function() {
callback(null, 0);
}, 1000);
};
work.b = function(callback) {
setTimeout(function() {
callback(null, 1);
callback(new Error('Something bad happened'));
}, 500);
};
work.c = function(callback) {
setTimeout(function() {
callback(null, 2);
}, 0);
};
async.parallel(work, function(err, results) {
expect(results).to.deep.equal({a: 0, b: 1, c: 2});
expect(uncaughtException.toString().indexOf('Something bad happened')).to.not.equal(-1);
done();
});
});

@@ -142,0 +186,0 @@

'use strict';
require('chai').should();
require('chai').Assertion.includeStack = true;
require('chai').config.includeStack = true;
var expect = require('chai').expect;

@@ -23,3 +23,3 @@

it('should return array results in correct order', function(done) {
this.timeout(2000);

@@ -55,3 +55,3 @@

it('should throw error if callback for job is invoked more than once', function(done) {
var uncaughtException;

@@ -94,3 +94,3 @@

expect(results).to.deep.equal([0, 1, 2]);
expect(uncaughtException.toString()).to.equal('Error: callback for async operation at index 1 invoked more than once');
expect(uncaughtException.toString()).to.equal('Error: callback for async operation at index \"1\" invoked after completion. (no error)');
done();

@@ -101,2 +101,47 @@ });

it('should include original error if callback is invoked after completion', function(done) {
var uncaughtException;
var mochaExceptionHandler = process.listeners('uncaughtException').pop();
process.removeListener('uncaughtException', mochaExceptionHandler);
process.once('uncaughtException', function(err) {
// errors for invoking callback more than once will be thrown as errors
// since they fall into the unexpected exception category
uncaughtException = err;
process.on('uncaughtException', mochaExceptionHandler);
});
this.timeout(2000);
var work = [];
work[0] = function(callback) {
setTimeout(function() {
callback(null, 0);
}, 500);
};
work[1] = function(callback) {
setTimeout(function() {
callback(null, 1);
callback(new Error('Something bad happened'));
}, 250);
};
work[2] = function(callback) {
setTimeout(function() {
callback(null, 2);
}, 0);
};
async.series(work, function(err, results) {
expect(results).to.deep.equal([0, 1, 2]);
expect(uncaughtException.toString().indexOf('Something bad happened')).to.not.equal(-1);
done();
});
});
it('should handle errors for arrays as input', function(done) {

@@ -103,0 +148,0 @@