Comparing version 0.2.0 to 0.3.0
@@ -1,1 +0,1 @@ | ||
!function(n,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():n.aqueue=t()}(this,function(){"use strict";var n=function(n){function t(){o||(o=!0,setTimeout(function(){c()},0))}var e=[],u=-1,i=[],n=n||void 0,o=!1,c=function(){var t=[].slice.call(arguments),s=t.shift(),l=null;return s||!o?(s&&n.apply(this,[].slice.call(arguments)),o=!1,void(i=t)):(u=(u+1)%e.length,l=e[u],t=i.concat(t,l[1]),t.push(c),l[0].apply(c,t),void(i=[]))},s=function(){var n=[].slice.call(arguments),u=n.shift();return 0!==n.length&&u&&"function"==typeof u?(e.push([u,n]),t()):(console.log("---> pausing or stopping the queue"),!o&&e.length?t():o=!1),s};return s};return n}); | ||
!function(n,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():n.aqueue=t()}(this,function(){"use strict";function n(){}var t=function(t,e){function u(){c||(c=!0,setTimeout(function(){f()},0))}var i=[],o=-1,t=t||n,e=e||!1,c=!1,f=function(){var n=[].slice.call(arguments),u=n.shift(),r=null;return u||!c||o===i.length-1&&!e?(u&&t.apply(this,[].slice.call(arguments)),void(c=!1)):(o=(o+1)%i.length,r=i[o],n=n.concat(r[1]),n.push(f),void r[0].apply(f,n))},r=function(){var n=[].slice.call(arguments),t=n.shift();return t&&"function"==typeof t&&(i.push([t,n]),u()),r};return r};return t}); |
{ | ||
"name": "aqueue", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Lightweight queue for async tasks", | ||
@@ -5,0 +5,0 @@ "main": "src/aqueue.js", |
@@ -69,3 +69,3 @@ /* | ||
if (args.length !== 0 && fn && typeof fn === 'function') { | ||
if (fn && typeof fn === 'function') { | ||
queue.push([fn, args]); | ||
@@ -72,0 +72,0 @@ run(); |
@@ -22,20 +22,19 @@ var assert = require('assert'); | ||
setTimeout(function() { | ||
next(null, a); | ||
next(null, 'happy'); | ||
}, 100); | ||
} | ||
var b = function(a, b, next) { | ||
var b = function(b, next) { | ||
console.log('in b..'); | ||
assert.equal(a, 'test'); | ||
assert.equal(b, 'passed'); | ||
assert.equal(b, 'happy'); | ||
console.log('* TESTING *', a, b); | ||
console.log('* TESTING *', b); | ||
setTimeout(function() { | ||
next(null, a, b); | ||
next(null, b); | ||
}, 500); | ||
} | ||
var c = function(a, b, c, d, next) { | ||
var c = function(a, b, c, next) { | ||
console.log('in c...'); | ||
assert.deepEqual("the test has passed".split(" "), [c, a, d, b]); | ||
assert.deepEqual("the happy has".split(" "), [b, a, c]); | ||
next('error', 'Test', 'finished.'); | ||
@@ -45,3 +44,3 @@ // next(null); => by default it won't repeat | ||
queue(a, 'test')()(b, 'passed'); | ||
queue(a, 'test')(b); | ||
queue(c, 'the', 'has'); |
4921
135