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

es6-promise-pool

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-promise-pool - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

65

es6-promise-pool.js

@@ -14,2 +14,13 @@ (function(global) {

var promiseToProducer = function(promise) {
var called = false;
return function() {
if (called) {
return null;
}
called = true;
return promise;
};
};
var toProducer = function(obj) {

@@ -27,10 +38,3 @@ var type = typeof obj;

}
var called = false;
return function() {
if (called) {
return null;
}
called = true;
return obj;
};
return promiseToProducer(obj);
};

@@ -56,4 +60,4 @@

this._size = 0;
this._resolve = null;
this._reject = null;
this._promise = null;
this._callbacks = null;
};

@@ -64,3 +68,3 @@

this._concurrency = value;
if (this._resolve) {
if (this.active()) {
this._proceed();

@@ -76,9 +80,20 @@ }

PromisePool.prototype.active = function() {
return !!this._promise;
};
PromisePool.prototype.promise = function() {
return this._promise;
};
PromisePool.prototype.start = function() {
var that = this;
return new Promise(function(resolve, reject) {
that._resolve = resolve;
that._reject = reject;
this._promise = new Promise(function(resolve, reject) {
that._callbacks = {
reject: reject,
resolve: resolve
};
that._proceed();
});
return this._promise;
};

@@ -114,7 +129,8 @@

if (error) {
this._reject(error);
this._callbacks.reject(error);
} else {
this._resolve();
this._callbacks.resolve();
}
this._resolve = this._reject = null;
this._promise = null;
this._callbacks = null;
};

@@ -124,3 +140,3 @@

this._size--;
if (this._resolve) {
if (this.active()) {
this._fireEvent('fulfilled', {

@@ -136,3 +152,3 @@ promise: promise,

this._size--;
if (this._reject) {
if (this.active()) {
this._fireEvent('rejected', {

@@ -179,3 +195,3 @@ promise: promise,

listeners[eventType] = function(evt) {
cb(evt.target, evt.data.promise, evt.data[eventKey]);
cb(evt.target._promise, evt.data.promise, evt.data[eventKey]);
};

@@ -194,12 +210,7 @@ }

// Legacy API: options.onresolve and options.onreject
var listeners;
if (options) {
listeners = modernizeOptions(options);
}
var listeners = options ? modernizeOptions(options) : null;
var pool = new PromisePool(source, concurrency, options);
if (listeners) {
for (var type in listeners) {
if (listeners.hasOwnProperty(type)) {
pool.addEventListener(type, listeners[type]);
}
pool.addEventListener(type, listeners[type]);
}

@@ -206,0 +217,0 @@ }

{
"name": "es6-promise-pool",
"version": "0.2.1",
"version": "0.2.2",
"description": "Runs Promises in a pool that limits their maximum concurrency.",

@@ -5,0 +5,0 @@ "author": {

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