[Pkg-javascript-commits] [node-async] 449/480: Add in started attribute for queue. Helpful for displaying whether or not that queue has processed any jobs

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:50 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 7fc85d7bb1bb252a58cf123c4a2f75ef33cee60b
Author: Jon Morehouse <morehousej09 at gmail.com>
Date:   Sat Apr 5 23:31:27 2014 -0700

    Add in started attribute for queue. Helpful for displaying whether or not that queue has processed any jobs
---
 README.md          |  3 ++-
 lib/async.js       |  4 ++++
 test/test-async.js | 13 +++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 53dedba..1835942 100644
--- a/README.md
+++ b/README.md
@@ -918,7 +918,7 @@ async.waterfall([
         callback(null, 'one', 'two');
     },
     function(arg1, arg2, callback){
-    	// arg1 now equals 'one' and arg2 now equals 'two'
+      // arg1 now equals 'one' and arg2 now equals 'two'
         callback(null, 'three');
     },
     function(arg1, callback){
@@ -1076,6 +1076,7 @@ The `queue` object returned by this function has the following properties and
 methods:
 
 * `length()` - a function returning the number of items waiting to be processed.
+* `started` - a function returning whether or not any items have been pushed and processed by the queue
 * `running()` - a function returning the number of items currently being processed.
 * `idle()` - a function returning false if there are items waiting or being processed, or true if not.
 * `concurrency` - an integer for determining how many `worker` functions should be
diff --git a/lib/async.js b/lib/async.js
index a5ffffa..20afb3b 100755
--- a/lib/async.js
+++ b/lib/async.js
@@ -721,6 +721,9 @@
             concurrency = 1;
         }
         function _insert(q, data, pos, callback) {
+          if (!q.started){
+            q.started = true;
+          }
           if (!_isArray(data)) {
               data = [data];
           }
@@ -758,6 +761,7 @@
             saturated: null,
             empty: null,
             drain: null,
+            started: false,
             paused: false,
             push: function (data, callback) {
               _insert(q, data, false, callback);
diff --git a/test/test-async.js b/test/test-async.js
index 6d65c15..d9f2dee 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -2913,3 +2913,16 @@ exports['queue empty'] = function(test) {
     };
     q.push([]);
 };
+
+exports['queue started'] = function(test) {
+
+  var calls = [];
+  var q = async.queue(function(task, cb) {});
+  
+  test.equal(q.started, false);
+  q.push([]);
+  test.equal(q.started, true);
+  test.done();
+
+};
+

-- 
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