agraddy.async.series
Advanced tools
Comparing version
@@ -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; |
{ | ||
"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() { | ||
} | ||
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3338
69.87%90
800%1
Infinity%+ Added
+ Added