New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bottleneck

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bottleneck - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

scripts/build.sh

4

bottleneck.js

@@ -41,3 +41,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

this.minTime = minTime != null ? minTime : 0;
this.highWater = highWater != null ? highWater : 0;
this.highWater = highWater != null ? highWater : -1;
this.strategy = strategy != null ? strategy : Bottleneck.prototype.strategy.LEAK;

@@ -192,3 +192,3 @@ this.schedulePriority = bind(this.schedulePriority, this);

priority = this._sanitizePriority(priority);
reachedHighWaterMark = this.highWater > 0 && this.nbQueued() === this.highWater;
reachedHighWaterMark = this.highWater >= 0 && this.nbQueued() === this.highWater && !this.check();
if (this.strategy === Bottleneck.prototype.strategy.BLOCK && (reachedHighWaterMark || this.isBlocked())) {

@@ -195,0 +195,0 @@ this._unblockTime = Date.now() + this.penalty;

@@ -1,1 +0,1 @@

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){(function(){var Bottleneck,MIDDLE_PRIORITY,NB_PRIORITIES,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},slice=[].slice;NB_PRIORITIES=10;MIDDLE_PRIORITY=5;Bottleneck=function(){var e;Bottleneck.strategy=Bottleneck.prototype.strategy={LEAK:1,OVERFLOW:2,OVERFLOW_PRIORITY:4,BLOCK:3};Bottleneck.Cluster=Bottleneck.prototype.Cluster=require("./Cluster");Bottleneck.DLList=Bottleneck.prototype.DLList=require("./DLList");Bottleneck.Promise=Bottleneck.prototype.Promise=function(){var error1;try{return require("bluebird")}catch(error1){e=error1;return typeof Promise!=="undefined"&&Promise!==null?Promise:function(){throw new Error("Bottleneck: install 'bluebird' or use Node 0.12 or higher for Promise support")}}}();function Bottleneck(maxNb,minTime,highWater,strategy){this.maxNb=maxNb!=null?maxNb:0;this.minTime=minTime!=null?minTime:0;this.highWater=highWater!=null?highWater:0;this.strategy=strategy!=null?strategy:Bottleneck.prototype.strategy.LEAK;this.schedulePriority=bind(this.schedulePriority,this);this.submitPriority=bind(this.submitPriority,this);this.submit=bind(this.submit,this);this._nextRequest=Date.now();this._nbRunning=0;this._queues=this._makeQueues();this._timeouts=[];this._unblockTime=0;this.penalty=15*this.minTime||5e3;this.interrupt=false;this.reservoir=null;this.limiter=null;this.events={}}Bottleneck.prototype._trigger=function(name,args){return setTimeout(function(_this){return function(){var ref;return(ref=_this.events[name])!=null?ref.forEach(function(e){return e.apply({},args)}):void 0}}(this),0)};Bottleneck.prototype._makeQueues=function(){var i,j,ref,results;results=[];for(i=j=1,ref=NB_PRIORITIES;1<=ref?j<=ref:j>=ref;i=1<=ref?++j:--j){results.push(new Bottleneck.prototype.DLList)}return results};Bottleneck.prototype.chain=function(limiter){this.limiter=limiter;return this};Bottleneck.prototype.isBlocked=function(){return this._unblockTime>=Date.now()};Bottleneck.prototype._sanitizePriority=function(priority){var sProperty;sProperty=~~priority!==priority?MIDDLE_PRIORITY:priority;if(sProperty<0){return 0}else if(sProperty>NB_PRIORITIES-1){return NB_PRIORITIES-1}else{return sProperty}};Bottleneck.prototype._find=function(arr,fn){var i,j,len,x;for(i=j=0,len=arr.length;j<len;i=++j){x=arr[i];if(fn(x)){return x}}return[]};Bottleneck.prototype.nbQueued=function(priority){if(priority!=null){return this._queues[this._sanitizePriority(priority)].length}else{return this._queues.reduce(function(a,b){return a+b.length},0)}};Bottleneck.prototype._getFirst=function(arr){return this._find(arr,function(x){return x.length>0})};Bottleneck.prototype._conditionsCheck=function(){return(this._nbRunning<this.maxNb||this.maxNb<=0)&&(this.reservoir==null||this.reservoir>0)};Bottleneck.prototype.check=function(){return this._conditionsCheck()&&this._nextRequest-Date.now()<=0};Bottleneck.prototype._tryToRun=function(){var done,index,next,queued,wait;if(this._conditionsCheck()&&(queued=this.nbQueued())>0){this._nbRunning++;if(this.reservoir!=null){this.reservoir--}wait=Math.max(this._nextRequest-Date.now(),0);this._nextRequest=Date.now()+wait+this.minTime;next=this._getFirst(this._queues).shift();if(queued===1){this._trigger("empty",[])}done=false;index=-1+this._timeouts.push(setTimeout(function(_this){return function(){var completed;completed=function(){var ref;if(!done){done=true;delete _this._timeouts[index];_this._nbRunning--;_this._tryToRun();if(!_this.interrupt){return(ref=next.cb)!=null?ref.apply({},Array.prototype.slice.call(arguments,0)):void 0}}};if(_this.limiter!=null){return _this.limiter.submit.apply(_this.limiter,Array.prototype.concat(next.task,next.args,completed))}else{return next.task.apply({},next.args.concat(completed))}}}(this),wait));return true}else{return false}};Bottleneck.prototype.submit=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return this.submitPriority.apply({},Array.prototype.concat(MIDDLE_PRIORITY,args))};Bottleneck.prototype.submitPriority=function(){var args,cb,j,job,priority,reachedHighWaterMark,shifted,task;priority=arguments[0],task=arguments[1],args=4<=arguments.length?slice.call(arguments,2,j=arguments.length-1):(j=2,[]),cb=arguments[j++];job={task:task,args:args,cb:cb};priority=this._sanitizePriority(priority);reachedHighWaterMark=this.highWater>0&&this.nbQueued()===this.highWater;if(this.strategy===Bottleneck.prototype.strategy.BLOCK&&(reachedHighWaterMark||this.isBlocked())){this._unblockTime=Date.now()+this.penalty;this._nextRequest=this._unblockTime+this.minTime;this._queues=this._makeQueues();this._trigger("dropped",[job]);return true}else if(reachedHighWaterMark){shifted=this.strategy===Bottleneck.prototype.strategy.LEAK?this._getFirst(this._queues.slice(priority).reverse()).shift():this.strategy===Bottleneck.prototype.strategy.OVERFLOW_PRIORITY?this._getFirst(this._queues.slice(priority+1).reverse()).shift():this.strategy===Bottleneck.prototype.strategy.OVERFLOW?job:void 0;if(shifted!=null){this._trigger("dropped",[shifted])}if(shifted==null||this.strategy===Bottleneck.prototype.strategy.OVERFLOW){return reachedHighWaterMark}}this._queues[priority].push(job);this._tryToRun();return reachedHighWaterMark};Bottleneck.prototype.schedule=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return this.schedulePriority.apply({},Array.prototype.concat(MIDDLE_PRIORITY,args))};Bottleneck.prototype.schedulePriority=function(){var args,priority,task,wrapped;priority=arguments[0],task=arguments[1],args=3<=arguments.length?slice.call(arguments,2):[];wrapped=function(cb){return task.apply({},args).then(function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return cb.apply({},Array.prototype.concat(null,args))})["catch"](function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return cb.apply({},Array.prototype.concat({},args))})};return new Bottleneck.prototype.Promise(function(_this){return function(resolve,reject){return _this.submitPriority.apply({},Array.prototype.concat(priority,wrapped,function(){var args,error;error=arguments[0],args=2<=arguments.length?slice.call(arguments,1):[];return(error!=null?reject:resolve).apply({},args)}))}}(this))};Bottleneck.prototype.changeSettings=function(maxNb,minTime,highWater,strategy){this.maxNb=maxNb!=null?maxNb:this.maxNb;this.minTime=minTime!=null?minTime:this.minTime;this.highWater=highWater!=null?highWater:this.highWater;this.strategy=strategy!=null?strategy:this.strategy;while(this._tryToRun()){}return this};Bottleneck.prototype.changePenalty=function(penalty){this.penalty=penalty!=null?penalty:this.penalty;return this};Bottleneck.prototype.changeReservoir=function(reservoir){this.reservoir=reservoir;while(this._tryToRun()){}return this};Bottleneck.prototype.incrementReservoir=function(incr){if(incr==null){incr=0}this.changeReservoir(this.reservoir+incr);return this};Bottleneck.prototype.on=function(name,cb){if(this.events[name]!=null){this.events[name].push(cb)}else{this.events[name]=[cb]}return this};Bottleneck.prototype.stopAll=function(interrupt){var a,j,len,ref;this.interrupt=interrupt!=null?interrupt:this.interrupt;ref=this._timeouts;for(j=0,len=ref.length;j<len;j++){a=ref[j];clearTimeout(a)}this._tryToRun=function(){};return this.check=this.submit=this.submitPriority=this.schedule=this.schedulePriority=function(){return false}};return Bottleneck}();module.exports=Bottleneck}).call(this)},{"./Cluster":2,"./DLList":3,bluebird:undefined}],2:[function(require,module,exports){(function(){var Cluster,hasProp={}.hasOwnProperty;Cluster=function(){function Cluster(maxNb,minTime,highWater,strategy){this.maxNb=maxNb;this.minTime=minTime;this.highWater=highWater;this.strategy=strategy;this.limiters={};this.Bottleneck=require("./Bottleneck");this.startAutoCleanup()}Cluster.prototype.key=function(key){var ref;if(key==null){key=""}return(ref=this.limiters[key])!=null?ref:this.limiters[key]=new this.Bottleneck(this.maxNb,this.minTime,this.highWater,this.strategy)};Cluster.prototype.deleteKey=function(key){if(key==null){key=""}return delete this.limiters[key]};Cluster.prototype.all=function(cb){var k,ref,results,v;ref=this.limiters;results=[];for(k in ref){if(!hasProp.call(ref,k))continue;v=ref[k];results.push(cb(v))}return results};Cluster.prototype.keys=function(){return Object.keys(this.limiters)};Cluster.prototype.startAutoCleanup=function(){var base;this.stopAutoCleanup();return typeof(base=this.interval=setInterval(function(_this){return function(){var k,ref,results,time,v;time=Date.now();ref=_this.limiters;results=[];for(k in ref){v=ref[k];if(v._nextRequest+1e3*60*5<time){results.push(_this.deleteKey(k))}else{results.push(void 0)}}return results}}(this),1e3*30)).unref==="function"?base.unref():void 0};Cluster.prototype.stopAutoCleanup=function(){return clearInterval(this.interval)};return Cluster}();module.exports=Cluster}).call(this)},{"./Bottleneck":1}],3:[function(require,module,exports){(function(){var DLList;DLList=function(){function DLList(){this._first=null;this._last=null;this.length=0}DLList.prototype.push=function(value){var node;this.length++;node={value:value,next:null};if(this._last!=null){this._last.next=node;this._last=node}else{this._first=this._last=node}return void 0};DLList.prototype.shift=function(){var ref1,value;if(this._first==null){return void 0}else{this.length--}value=this._first.value;this._first=(ref1=this._first.next)!=null?ref1:this._last=null;return value};DLList.prototype.getArray=function(){var node,ref,results;node=this._first;results=[];while(node!=null){results.push((ref=node,node=node.next,ref.value))}return results};return DLList}();module.exports=DLList}).call(this)},{}],4:[function(require,module,exports){(function(global){(function(){module.exports=require("./Bottleneck");if(global.window!=null){global.window.Bottleneck=module.exports}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./Bottleneck":1}]},{},[4]);
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){(function(){var Bottleneck,MIDDLE_PRIORITY,NB_PRIORITIES,bind=function(fn,me){return function(){return fn.apply(me,arguments)}},slice=[].slice;NB_PRIORITIES=10;MIDDLE_PRIORITY=5;Bottleneck=function(){var e;Bottleneck.strategy=Bottleneck.prototype.strategy={LEAK:1,OVERFLOW:2,OVERFLOW_PRIORITY:4,BLOCK:3};Bottleneck.Cluster=Bottleneck.prototype.Cluster=require("./Cluster");Bottleneck.DLList=Bottleneck.prototype.DLList=require("./DLList");Bottleneck.Promise=Bottleneck.prototype.Promise=function(){var error1;try{return require("bluebird")}catch(error1){e=error1;return typeof Promise!=="undefined"&&Promise!==null?Promise:function(){throw new Error("Bottleneck: install 'bluebird' or use Node 0.12 or higher for Promise support")}}}();function Bottleneck(maxNb,minTime,highWater,strategy){this.maxNb=maxNb!=null?maxNb:0;this.minTime=minTime!=null?minTime:0;this.highWater=highWater!=null?highWater:-1;this.strategy=strategy!=null?strategy:Bottleneck.prototype.strategy.LEAK;this.schedulePriority=bind(this.schedulePriority,this);this.submitPriority=bind(this.submitPriority,this);this.submit=bind(this.submit,this);this._nextRequest=Date.now();this._nbRunning=0;this._queues=this._makeQueues();this._timeouts=[];this._unblockTime=0;this.penalty=15*this.minTime||5e3;this.interrupt=false;this.reservoir=null;this.limiter=null;this.events={}}Bottleneck.prototype._trigger=function(name,args){return setTimeout(function(_this){return function(){var ref;return(ref=_this.events[name])!=null?ref.forEach(function(e){return e.apply({},args)}):void 0}}(this),0)};Bottleneck.prototype._makeQueues=function(){var i,j,ref,results;results=[];for(i=j=1,ref=NB_PRIORITIES;1<=ref?j<=ref:j>=ref;i=1<=ref?++j:--j){results.push(new Bottleneck.prototype.DLList)}return results};Bottleneck.prototype.chain=function(limiter){this.limiter=limiter;return this};Bottleneck.prototype.isBlocked=function(){return this._unblockTime>=Date.now()};Bottleneck.prototype._sanitizePriority=function(priority){var sProperty;sProperty=~~priority!==priority?MIDDLE_PRIORITY:priority;if(sProperty<0){return 0}else if(sProperty>NB_PRIORITIES-1){return NB_PRIORITIES-1}else{return sProperty}};Bottleneck.prototype._find=function(arr,fn){var i,j,len,x;for(i=j=0,len=arr.length;j<len;i=++j){x=arr[i];if(fn(x)){return x}}return[]};Bottleneck.prototype.nbQueued=function(priority){if(priority!=null){return this._queues[this._sanitizePriority(priority)].length}else{return this._queues.reduce(function(a,b){return a+b.length},0)}};Bottleneck.prototype._getFirst=function(arr){return this._find(arr,function(x){return x.length>0})};Bottleneck.prototype._conditionsCheck=function(){return(this._nbRunning<this.maxNb||this.maxNb<=0)&&(this.reservoir==null||this.reservoir>0)};Bottleneck.prototype.check=function(){return this._conditionsCheck()&&this._nextRequest-Date.now()<=0};Bottleneck.prototype._tryToRun=function(){var done,index,next,queued,wait;if(this._conditionsCheck()&&(queued=this.nbQueued())>0){this._nbRunning++;if(this.reservoir!=null){this.reservoir--}wait=Math.max(this._nextRequest-Date.now(),0);this._nextRequest=Date.now()+wait+this.minTime;next=this._getFirst(this._queues).shift();if(queued===1){this._trigger("empty",[])}done=false;index=-1+this._timeouts.push(setTimeout(function(_this){return function(){var completed;completed=function(){var ref;if(!done){done=true;delete _this._timeouts[index];_this._nbRunning--;_this._tryToRun();if(!_this.interrupt){return(ref=next.cb)!=null?ref.apply({},Array.prototype.slice.call(arguments,0)):void 0}}};if(_this.limiter!=null){return _this.limiter.submit.apply(_this.limiter,Array.prototype.concat(next.task,next.args,completed))}else{return next.task.apply({},next.args.concat(completed))}}}(this),wait));return true}else{return false}};Bottleneck.prototype.submit=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return this.submitPriority.apply({},Array.prototype.concat(MIDDLE_PRIORITY,args))};Bottleneck.prototype.submitPriority=function(){var args,cb,j,job,priority,reachedHighWaterMark,shifted,task;priority=arguments[0],task=arguments[1],args=4<=arguments.length?slice.call(arguments,2,j=arguments.length-1):(j=2,[]),cb=arguments[j++];job={task:task,args:args,cb:cb};priority=this._sanitizePriority(priority);reachedHighWaterMark=this.highWater>=0&&this.nbQueued()===this.highWater&&!this.check();if(this.strategy===Bottleneck.prototype.strategy.BLOCK&&(reachedHighWaterMark||this.isBlocked())){this._unblockTime=Date.now()+this.penalty;this._nextRequest=this._unblockTime+this.minTime;this._queues=this._makeQueues();this._trigger("dropped",[job]);return true}else if(reachedHighWaterMark){shifted=this.strategy===Bottleneck.prototype.strategy.LEAK?this._getFirst(this._queues.slice(priority).reverse()).shift():this.strategy===Bottleneck.prototype.strategy.OVERFLOW_PRIORITY?this._getFirst(this._queues.slice(priority+1).reverse()).shift():this.strategy===Bottleneck.prototype.strategy.OVERFLOW?job:void 0;if(shifted!=null){this._trigger("dropped",[shifted])}if(shifted==null||this.strategy===Bottleneck.prototype.strategy.OVERFLOW){return reachedHighWaterMark}}this._queues[priority].push(job);this._tryToRun();return reachedHighWaterMark};Bottleneck.prototype.schedule=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return this.schedulePriority.apply({},Array.prototype.concat(MIDDLE_PRIORITY,args))};Bottleneck.prototype.schedulePriority=function(){var args,priority,task,wrapped;priority=arguments[0],task=arguments[1],args=3<=arguments.length?slice.call(arguments,2):[];wrapped=function(cb){return task.apply({},args).then(function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return cb.apply({},Array.prototype.concat(null,args))})["catch"](function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return cb.apply({},Array.prototype.concat({},args))})};return new Bottleneck.prototype.Promise(function(_this){return function(resolve,reject){return _this.submitPriority.apply({},Array.prototype.concat(priority,wrapped,function(){var args,error;error=arguments[0],args=2<=arguments.length?slice.call(arguments,1):[];return(error!=null?reject:resolve).apply({},args)}))}}(this))};Bottleneck.prototype.changeSettings=function(maxNb,minTime,highWater,strategy){this.maxNb=maxNb!=null?maxNb:this.maxNb;this.minTime=minTime!=null?minTime:this.minTime;this.highWater=highWater!=null?highWater:this.highWater;this.strategy=strategy!=null?strategy:this.strategy;while(this._tryToRun()){}return this};Bottleneck.prototype.changePenalty=function(penalty){this.penalty=penalty!=null?penalty:this.penalty;return this};Bottleneck.prototype.changeReservoir=function(reservoir){this.reservoir=reservoir;while(this._tryToRun()){}return this};Bottleneck.prototype.incrementReservoir=function(incr){if(incr==null){incr=0}this.changeReservoir(this.reservoir+incr);return this};Bottleneck.prototype.on=function(name,cb){if(this.events[name]!=null){this.events[name].push(cb)}else{this.events[name]=[cb]}return this};Bottleneck.prototype.stopAll=function(interrupt){var a,j,len,ref;this.interrupt=interrupt!=null?interrupt:this.interrupt;ref=this._timeouts;for(j=0,len=ref.length;j<len;j++){a=ref[j];clearTimeout(a)}this._tryToRun=function(){};return this.check=this.submit=this.submitPriority=this.schedule=this.schedulePriority=function(){return false}};return Bottleneck}();module.exports=Bottleneck}).call(this)},{"./Cluster":2,"./DLList":3,bluebird:undefined}],2:[function(require,module,exports){(function(){var Cluster,hasProp={}.hasOwnProperty;Cluster=function(){function Cluster(maxNb,minTime,highWater,strategy){this.maxNb=maxNb;this.minTime=minTime;this.highWater=highWater;this.strategy=strategy;this.limiters={};this.Bottleneck=require("./Bottleneck");this.startAutoCleanup()}Cluster.prototype.key=function(key){var ref;if(key==null){key=""}return(ref=this.limiters[key])!=null?ref:this.limiters[key]=new this.Bottleneck(this.maxNb,this.minTime,this.highWater,this.strategy)};Cluster.prototype.deleteKey=function(key){if(key==null){key=""}return delete this.limiters[key]};Cluster.prototype.all=function(cb){var k,ref,results,v;ref=this.limiters;results=[];for(k in ref){if(!hasProp.call(ref,k))continue;v=ref[k];results.push(cb(v))}return results};Cluster.prototype.keys=function(){return Object.keys(this.limiters)};Cluster.prototype.startAutoCleanup=function(){var base;this.stopAutoCleanup();return typeof(base=this.interval=setInterval(function(_this){return function(){var k,ref,results,time,v;time=Date.now();ref=_this.limiters;results=[];for(k in ref){v=ref[k];if(v._nextRequest+1e3*60*5<time){results.push(_this.deleteKey(k))}else{results.push(void 0)}}return results}}(this),1e3*30)).unref==="function"?base.unref():void 0};Cluster.prototype.stopAutoCleanup=function(){return clearInterval(this.interval)};return Cluster}();module.exports=Cluster}).call(this)},{"./Bottleneck":1}],3:[function(require,module,exports){(function(){var DLList;DLList=function(){function DLList(){this._first=null;this._last=null;this.length=0}DLList.prototype.push=function(value){var node;this.length++;node={value:value,next:null};if(this._last!=null){this._last.next=node;this._last=node}else{this._first=this._last=node}return void 0};DLList.prototype.shift=function(){var ref1,value;if(this._first==null){return void 0}else{this.length--}value=this._first.value;this._first=(ref1=this._first.next)!=null?ref1:this._last=null;return value};DLList.prototype.getArray=function(){var node,ref,results;node=this._first;results=[];while(node!=null){results.push((ref=node,node=node.next,ref.value))}return results};return DLList}();module.exports=DLList}).call(this)},{}],4:[function(require,module,exports){(function(global){(function(){module.exports=require("./Bottleneck");if(global.window!=null){global.window.Bottleneck=module.exports}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./Bottleneck":1}]},{},[4]);
{
"name": "bottleneck",
"main": "bottleneck.js",
"version": "1.11.0",
"version": "1.12.0",
"homepage": "https://github.com/SGrondin/bottleneck",

@@ -6,0 +6,0 @@ "authors": [

@@ -40,3 +40,3 @@ // Generated by CoffeeScript 1.10.0

this.minTime = minTime != null ? minTime : 0;
this.highWater = highWater != null ? highWater : 0;
this.highWater = highWater != null ? highWater : -1;
this.strategy = strategy != null ? strategy : Bottleneck.prototype.strategy.LEAK;

@@ -191,3 +191,3 @@ this.schedulePriority = bind(this.schedulePriority, this);

priority = this._sanitizePriority(priority);
reachedHighWaterMark = this.highWater > 0 && this.nbQueued() === this.highWater;
reachedHighWaterMark = this.highWater >= 0 && this.nbQueued() === this.highWater && !this.check();
if (this.strategy === Bottleneck.prototype.strategy.BLOCK && (reachedHighWaterMark || this.isBlocked())) {

@@ -194,0 +194,0 @@ this._unblockTime = Date.now() + this.penalty;

{
"name": "bottleneck",
"version": "1.11.0",
"version": "1.12.0",
"description": "Async rate limiter",

@@ -8,3 +8,4 @@ "main": "lib/index.js",

"test": "./node_modules/mocha/bin/mocha test/index.js",
"make": "./scripts/recompile.sh"
"build": "./scripts/build.sh",
"compile": "./scripts/build.sh compile"
},

@@ -11,0 +12,0 @@ "repository": {

@@ -70,3 +70,3 @@ # bottleneck

* `minTime` : How long to wait after launching a request before launching another one. *Default: `0`ms*
* `highWater` : How long can the queue get? *Default: `0` (unlimited)*
* `highWater` : How long can the queue get? *Default: `-1` (unlimited)*
* `strategy` : Which strategy to use if the queue gets longer than the high water mark. *Default: `Bottleneck.strategy.LEAK`.*

@@ -278,3 +278,3 @@

* `highWater` is set to `0` (default), which prevents the strategy from ever being run **OR** you never exceed the `highWater`.
* `highWater` is set to `-1` (default), which prevents the strategy from ever being run **OR** you never exceed the `highWater`.
* `maxConcurrent` is set to `0` (default) **OR** all requests call the callback *eventually* (in the case of promises, they must be resolved or rejected eventually).

@@ -281,0 +281,0 @@ * `reservoir` is `null` (default).

@@ -45,5 +45,5 @@ describe('General', function () {

var c = makeTest(1, 250)
var called = false
var called = 0
c.limiter.on('empty', function () { called = true })
c.limiter.on('empty', function () { called++ })

@@ -56,4 +56,4 @@ c.pNoErrVal(c.limiter.schedule(c.promise, null, 1), 1)

c.checkDuration(500)
console.assert(c.asserts() == 3)
console.assert(called)
console.assert(c.asserts() === 3)
console.assert(called === 2)
done()

@@ -63,2 +63,36 @@ })

})
describe('High water limit', function () {
it('Should support highWater set to 0', function (done) {
var c = makeTest(1, 250, 0)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 1), 1)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 2), 2)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 3), 3)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 4), 4)
c.limiter.changeSettings(null, null, -1)
c.last(function (err, results) {
c.checkDuration(0)
c.checkResultsOrder([1])
console.assert(c.asserts() === 1)
done()
})
})
it('Should support highWater set to 1', function (done) {
var c = makeTest(1, 250, 1)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 1), 1)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 2), 2)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 3), 3)
c.pNoErrVal(c.limiter.schedule(c.promise, null, 4), 4)
c.limiter.changeSettings(null, null, -1)
c.last(function (err, results) {
c.checkDuration(250)
c.checkResultsOrder([1,4])
console.assert(c.asserts() === 2)
done()
})
})
})
})

@@ -42,3 +42,3 @@ describe('Priority', function () {

c.limiter.submitPriority(9, c.job, null, 7, c.noErrVal(7))
c.limiter.changeSettings(null, null, 0)
c.limiter.changeSettings(null, null, -1)
c.last(function (err, results) {

@@ -71,3 +71,3 @@ c.checkDuration(500)

c.limiter.submitPriority(9, c.job, null, 7, c.noErrVal(7))
c.limiter.changeSettings(null, null, 0)
c.limiter.changeSettings(null, null, -1)
c.last(function (err, results) {

@@ -99,3 +99,3 @@ c.checkDuration(500)

c.limiter.submitPriority(2, c.job, null, 7, c.noErrVal(7))
c.limiter.changeSettings(null, null, 0)
c.limiter.changeSettings(null, null, -1)
c.last(function (err, results) {

@@ -126,3 +126,3 @@ c.checkDuration(500)

c.limiter.submitPriority(2, c.job, null, 7, c.noErrVal(7))
c.limiter.changeSettings(null, null, 0)
c.limiter.changeSettings(null, null, -1)
c.limiter._unblockTime = 0

@@ -129,0 +129,0 @@ c.limiter._nextRequest = 0

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