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

after

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

after - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

20

lib/after.js
module.exports = after
function after(count, callback) {
function after(count, callback, err_cb) {
var bail = false;
proxy.count = count

@@ -9,8 +10,17 @@

function proxy(err) {
if (proxy.count <= 0) {
throw new Error('after called too many times');
}
--proxy.count;
// after first error, rest are passed to err_cb
if (err) {
return callback(err)
bail = true
callback(err);
// future error callbacks will go to error handler
return callback = (err_cb || function() {})
}
proxy.count === 0 && !bail && callback()
}
}
--proxy.count === 0 && callback()
}
}
{
"name": "after",
"description": "after - tiny flow control",
"version": "0.6.0",
"author": "Raynos <raynos2@gmail.com>",
"contributors": [
{ "name": "Raynos", "email": "raynos2@gmail.com", "url":"http://raynos.org" }
],
"scripts": {
"test": "make test"
},
"devDependencies": {
"mocha": "0.10.2"
},
"keywords": ["flowcontrol", "after", "flow", "control", "arch"],
"repository": "git://github.com/Raynos/after.js.git",
"main": "lib/after"
"name": "after",
"description": "after - tiny flow control",
"version": "0.7.0",
"author": "Raynos <raynos2@gmail.com>",
"contributors": [
{
"name": "Raynos",
"email": "raynos2@gmail.com",
"url": "http://raynos.org"
}
],
"scripts": {
"test": "mocha --ui tdd --reporter spec test/*.js"
},
"devDependencies": {
"mocha": "~1.8.1"
},
"keywords": [
"flowcontrol",
"after",
"flow",
"control",
"arch"
],
"repository": "git://github.com/Raynos/after.git",
"main": "lib/after"
}

@@ -67,4 +67,4 @@ # After [![Build Status][1]][2]

[1]: https://secure.travis-ci.org/Raynos/after.js.png
[2]: http://travis-ci.org/Raynos/after.js
[1]: https://secure.travis-ci.org/Raynos/after.png
[2]: http://travis-ci.org/Raynos/after
[3]: http://raynos.org/blog/2/Flow-control-in-node.js

@@ -76,2 +76,2 @@ [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307

[8]: http://github.com/Raynos/iterators
[9]: http://github.com/Raynos/composite
[9]: http://github.com/Raynos/composite
/*global suite, test*/
var assert = require("assert"),
after = require("../lib/after.js");
var assert = require("assert")
, after = require("../")
suite("After", function () {
test("exists", function () {
assert(typeof after === "function", "after is not a function");
assert(after.forEach, "forEach");
assert(after.map, "map");
assert(after.reduce, "reduce");
assert(after.reduceRight, "reduceRight");
assert(after.every, "every");
assert(after.filter, "filter");
assert(after.some, "some");
test("exists", function () {
assert(typeof after === "function", "after is not a function")
})
test("after when called with 0 invokes", function (done) {
after(0, done)
});
test("after 1", function (done) {
var next = after(1, done)
next()
})
test("after 5", function (done) {
var next = after(5, done)
, i = 5
while (i--) {
next()
}
})
test("manipulate count", function (done) {
var next = after(1, done)
, i = 5
next.count = i
while (i--) {
next()
}
})
test("after terminates on error", function (done) {
var next = after(2, function(err) {
assert.equal(err.message, 'test');
done();
})
next(new Error('test'))
next(new Error('test2'))
})
test('gee', function(done) {
done = after(2, done)
function cb(err) {
assert.equal(err.message, 1);
done()
}
var next = after(3, cb, function(err) {
assert.equal(err.message, 2)
done()
});
suite("after", function () {
test("after when called with 0 invokes", function (done) {
after(0, done)
});
next()
next(new Error(1))
next(new Error(2))
})
test("after 1", function (done) {
var next = after(1, call(done))
next()
})
test('eee', function(done) {
done = after(3, done)
test("after 5", function (done) {
var next = after(5, call(done))
, i = 5
function cb(err) {
assert.equal(err.message, 1);
done()
}
while (i--) {
next()
}
})
var next = after(3, cb, function(err) {
assert.equal(err.message, 2)
done()
});
test("manipulate count", function (done) {
var next = after(1, call(done))
, i = 5
next(new Error(1))
next(new Error(2))
next(new Error(2))
})
next.count = i
while (i--) {
next()
}
})
test('gge', function(done) {
function cb(err) {
assert.equal(err.message, 1);
done()
}
test("after terminates on error", function (done) {
var next = after(2, call(done))
var next = after(3, cb, function(err) {
// should not happen
assert.ok(false);
});
next({})
})
})
next()
next()
next(new Error(1))
})
function call(f) {
return function () {
f()
test('egg', function(done) {
function cb(err) {
assert.equal(err.message, 1);
done()
}
}
var next = after(3, cb, function(err) {
// should not happen
assert.ok(false);
});
next(new Error(1))
next()
next()
})
test('throws on too many calls', function(done) {
var next = after(1, done);
next()
assert.throws(next, /after called too many times/);
});

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