disconnect
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -0,1 +1,6 @@ | ||
0.3.1 / 2014-06-26 | ||
================== | ||
* Fixed a litte bug in the calculation of free positions in the request queue | ||
* Started adding unit tests using `wru` | ||
0.3.0 / 2014-06-24 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -23,3 +23,3 @@ var queue = module.exports = {}, | ||
function execute(){ | ||
stack.shift().call(this, null, (maxItems-stack.length)-1); | ||
stack.shift().callback.call(this, null, (maxItems-stack.length)); | ||
return this; | ||
@@ -42,9 +42,11 @@ } | ||
if(len < maxItems){ | ||
stack.push(callback); | ||
if(stack.length === 1){ // Immediate execution on empty queue | ||
callback(null, (maxItems-len)-1); | ||
setTimeout(remove, interval); // Remove from queue after interval | ||
var item = {}; | ||
if(len === 0){ // Immediate execution on empty queue | ||
callback(null, maxItems-1); | ||
item.timeout = setTimeout(remove, interval); // Remove from queue after interval | ||
}else{ // Queue | ||
setTimeout(execute, (len*interval)); | ||
item.callback = callback; | ||
item.timeout = setTimeout(execute, ((len+1)*interval)); | ||
} | ||
stack.push(item); | ||
}else{ | ||
@@ -57,2 +59,15 @@ callback(new DiscogsError(429, 'Too many requests'), 0); | ||
/** | ||
* Clear the request queue. All queued requests/callbacks will be cancelled! | ||
* @returns {Object} | ||
*/ | ||
queue.clear = function(){ | ||
var item; | ||
while(item = stack.shift()){ | ||
clearTimeout(item.timeout); | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Get the current queue length | ||
@@ -59,0 +74,0 @@ * @returns {Number} |
{ | ||
"name": "disconnect", | ||
"description": "Easy to use client to connect with the discogs.com API v2.0", | ||
"version": "0.3.0", | ||
"description": "An easy to use client library to connect with the discogs.com API v2.0", | ||
"version": "0.3.1", | ||
"keywords": ["discogs", "api", "client", "oauth"], | ||
@@ -22,3 +22,5 @@ "homepage": "https://github.com/bartve/disconnect", | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"wru": "0.2.x" | ||
}, | ||
"engines": { | ||
@@ -25,0 +27,0 @@ "node": ">= 0.10.0" |
@@ -17,3 +17,3 @@ ## About | ||
* Add tests! | ||
* Add more tests | ||
@@ -20,0 +20,0 @@ ## Installation |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
42611
20
1050
1
1