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

after-all

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

after-all - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

11

index.js
module.exports = function(afterAllCb) {
var errorMessage ='"next" function called after the final callback.'+
' Make sure all the calls to "next" are on the same tick';
var calls = 0;
var done = false;
return function next(cb) {
if (done) throw new Error(errorMessage);
calls++;

@@ -11,4 +15,7 @@

process.nextTick(function() {
cb.apply(null, args);
if (--calls === 0) afterAllCb();
if (cb) cb.apply(null, args);
if (--calls === 0) {
done = true;
afterAllCb();
}
});

@@ -15,0 +22,0 @@ }

2

package.json
{
"name": "after-all",
"version": "0.0.2",
"version": "0.0.3",
"description": "Execute several async functions and get a callback when they are all done",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,2 +5,10 @@ # after-all

## Installation
You can install it with npm.
```
npm install after-all
```
## Simple example

@@ -7,0 +15,0 @@

@@ -65,2 +65,23 @@ var afterAll = require('../index');

});
it('should work if the callback is not passed', function(done) {
var next = afterAll(function() {
done();
});
setTimeout(next(), 300);
});
it('should throw an error if the "next" function is called after the final callback is called', function(done) {
var next = afterAll(function() {});
next()();
process.nextTick(function() {
try {
next();
} catch(e) {
done();
}
});
});
});
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