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

agraddy.async.series

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agraddy.async.series - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

32

lib/index.js

@@ -1,7 +0,33 @@

var mod = {};
require('setimmediate');
mod.main = function(input) {
return input;
var mod = function(list, cb) {
var index = 0;
var funcs = list;
var finish = cb;
loop();
function loop() {
funcs[index].call(this, callback);
function callback(err) {
index++;
if(err) {
finish(err);
} else {
if(index < funcs.length) {
setImmediate(function() {
loop();
});
} else {
setImmediate(function() {
finish();
});
}
}
}
}
}
module.exports = mod;

13

package.json
{
"name": "agraddy.async.series",
"version": "0.1.0",
"version": "0.2.0",
"description": "Coming soon.",

@@ -13,11 +13,14 @@ "main": "index.js",

"repository": {
"type": "git",
"url": "git://github.com/agraddy/agraddy.async.series.git"
"type": "git",
"url": "git://github.com/agraddy/agraddy.async.series.git"
},
"bugs": {
"url": "https://github.com/agraddy/agraddy.async.series/issues"
"url": "https://github.com/agraddy/agraddy.async.series/issues"
},
"devDependencies": {
"agraddy.test.tap": "^0.4.0"
"agraddy.test.tap": "^0.4.0"
},
"dependencies": {
"setimmediate": "^1.0.5"
}
}

@@ -6,4 +6,69 @@ process.chdir('test');

tap.assert.equal(mod.main('result'), 'result', 'Should be equal.');
start();
function start() {
var list = [];
mod([
function(cb) {
list.push(1);
cb();
},
function(cb) {
list.push(2);
cb();
},
function(cb) {
list.push(3);
cb();
}
], function(err) {
tap.assert.deepEqual(list, [1,2,3], 'Should be equal.');
endEarly();
});
}
function endEarly() {
var list = [];
mod([
function(cb) {
list.push(1);
cb();
},
function(cb) {
list.push(2);
cb(new Error('End early'), 'one', 'two');
},
function(cb) {
list.push(3);
cb();
}
], function(err) {
tap.assert.equal(err.message, 'End early', 'An error should short circuit.');
tap.assert.deepEqual(list, [1,2], 'Should be equal.');
async();
});
}
function async() {
var i;
var list = [];
var func = function(cb) { cb() };
var order;
for(i = 0; i < 100; i++) {
list.push(func);
}
order = 'before';
mod(list, function(err) {
tap.assert.equal(order, 'after', 'Make sure it is actually async.');
end();
});
order = 'after';
}
function end() {
}
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