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

callback-count

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-count - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

.npmignore

4

index.js

@@ -20,3 +20,3 @@ var noop = function () {};

if (this.err) {
return; // already errored
return this; // already errored
}

@@ -28,3 +28,3 @@ else if (err) {

else {
this.count--;
if (this.count > 0) this.count--;
results = Array.prototype.slice.call(arguments, 1);

@@ -31,0 +31,0 @@ this.results.push(results);

{
"name": "callback-count",
"version": "0.0.3",
"version": "0.1.0",
"description": "Count your callbacks before continuing. A tiny control flow helper that supports dynamic counting.",

@@ -30,3 +30,7 @@ "main": "index.js",

},
"homepage": "https://github.com/tjmehta/callback-count"
"homepage": "https://github.com/tjmehta/callback-count",
"devDependencies": {
"should": "^3.1.3",
"mocha": "^1.17.1"
}
}

@@ -1,4 +0,64 @@

callback-count
callback-count [![Build Status](https://travis-ci.org/tjmehta/callback-count.png)](https://travis-ci.org/tjmehta/callback-count)
==============
Count callbacks before continuing, tiny control flow helper, allows dynamic counting.
#### Count callbacks before continuing, tiny control flow helper, allows dynamic counting.
### Flow control
```js
var counter = createCounter(done);
setTimeout(counter.inc().next, 100);
setTimeout(counter.inc().next, 100);
function done (err) {
console.log('finished.');
}
```
### .inc() allows you to dynamically update the number of callbacks you are expecting.
```js
var counter = createCounter(done);
counter.inc().inc().inc();
counter.next().next().next();
function done (err) {
console.log('finished.');
}
```
### The constructor can take an initial value for the count expected
```js
var counter = createCounter(3, done);
counter.next().next().next();
function done (err) {
console.log('finished.');
}
```
### .next() decrements the count and callsback when the count has reached 0
```js
var counter = createCounter(3, done);
counter.next().next().next();
function done (err) {
console.log(counter.count); // 0
console.log('finished.');
}
```
### if .next() receives an error it will callback immediately
```js
var counter = createCounter(3, done);
counter.next(new Error('boom'));
function done (err) {
console.log(err.message); // boom
}
```
### License: MIT
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