[Pkg-javascript-commits] [node-async] 56/480: allow queue.push without a callback

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 960b9bf4977754c6928b5507bfcee80dbe1a7c22
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Wed Nov 17 19:27:22 2010 +0000

    allow queue.push without a callback
---
 dist/async.min.js  |  2 +-
 lib/async.js       |  4 +++-
 test/test-async.js | 31 +++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/dist/async.min.js b/dist/async.min.js
index 53d4459..dfa2988 100644
--- a/dist/async.min.js
+++ b/dist/async.min.js
@@ -1 +1 @@
-/*global setTimeout: false, console: false */(function(){var a={};var b=this,c=b.async;typeof module!=="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){b.async=c;return a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)};var e=function(a,b){if(a.map)return a.map(b);var c=[];d(a,function(a,d,e){c.push(b(a,d,e))});return c};var f=function(a,b,c){if(a.reduce)return a.reduce(b,c);d(a,function(a,d,e){c=b(c,a,d,e)});ret [...]
\ No newline at end of file
+/*global setTimeout: false, console: false */(function(){var a={};var b=this,c=b.async;typeof module!=="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){b.async=c;return a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)};var e=function(a,b){if(a.map)return a.map(b);var c=[];d(a,function(a,d,e){c.push(b(a,d,e))});return c};var f=function(a,b,c){if(a.reduce)return a.reduce(b,c);d(a,function(a,d,e){c=b(c,a,d,e)});ret [...]
\ No newline at end of file
diff --git a/lib/async.js b/lib/async.js
index 62f2e43..c8fccc3 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -559,7 +559,9 @@
                     workers += 1;
                     worker(task.data, function () {
                         workers -= 1;
-                        task.callback.apply(task, arguments);
+                        if (task.callback) {
+                            task.callback.apply(task, arguments);
+                        }
                         q.process();
                     });
                 }
diff --git a/test/test-async.js b/test/test-async.js
index 1c694b5..73c42cf 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -1160,3 +1160,34 @@ exports['queue changing concurrency'] = function (test) {
         test.done();
     }, 100);
 };
+
+exports['queue push without callback'] = function (test) {
+    var call_order = [],
+        delays = [20,10,30,10];
+
+    // worker1: --1-4
+    // worker2: -2---3
+    // order of completion: 2,1,4,3
+
+    var q = async.queue(function (task, callback) {
+        setTimeout(function () {
+            call_order.push('process ' + task);
+            callback('error', 'arg');
+        }, delays.splice(0,1)[0]);
+    }, 2);
+
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    q.push(4);
+
+    setTimeout(function () {
+        test.same(call_order, [
+            'process 2',
+            'process 1',
+            'process 4',
+            'process 3'
+        ]);
+        test.done();
+    }, 60);
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list