Socket
Socket
Sign inDemoInstall

pend

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

4

index.js

@@ -29,7 +29,9 @@ module.exports = Pend;

self.pending += 1;
var called = false;
fn(onCb);
function onCb(err) {
if (called) throw new Error("callback called twice");
called = true;
self.error = self.error || err;
self.pending -= 1;
if (self.pending < 0) throw new Error("Callback called twice.");
if (self.waiting.length > 0 && self.pending < self.max) {

@@ -36,0 +38,0 @@ pendGo(self, self.waiting.shift());

{
"name": "pend",
"version": "1.1.0",
"version": "1.1.1",
"description": "dead-simple optimistic async helper",

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

@@ -10,2 +10,3 @@ # Pend

var pend = new Pend();
pend.max = 10; // defaults to Infinity
pend.go(function(cb) {

@@ -12,0 +13,0 @@ console.log("this function is immediately executed");

@@ -57,4 +57,15 @@ var assert = require('assert');

assert.deepEqual(results, ['a', 'b', 1, 'c', 1, 2]);
testCallbackTwice();
});
assert.deepEqual(results, ['a', 'b']);
}
function testCallbackTwice() {
var pend = new Pend();
pend.go(function(cb) {
});
pend.go(function(cb) {
cb();
assert.throws(cb, /callback called twice/);
});
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc