From b6bb1e69346477153d90a46ea44e9905c4f9071f Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Mon, 9 Oct 2017 11:29:33 -0400 Subject: [PATCH 1/2] Make the callback optional --- lib/jankyqueue.js | 2 ++ test/module-test.js | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/jankyqueue.js b/lib/jankyqueue.js index 3460158..25d3554 100644 --- a/lib/jankyqueue.js +++ b/lib/jankyqueue.js @@ -34,6 +34,8 @@ var Queue = function(max) { }; run = function(fn, args, callback) { + if (!callback) callback = function noop() {}; + var wrapped = function() { var results = arguments, next; diff --git a/test/module-test.js b/test/module-test.js index 46c09bd..6168b73 100644 --- a/test/module-test.js +++ b/test/module-test.js @@ -120,8 +120,36 @@ suite.addBatch({ assert.ifError(err); } } + }, + "and we create a third instance": { + topic: function(Queue) { + return new Queue(64); + }, + "it works": function(q) { + assert.ok(q); + }, + "and we enqueue some operations and don't specify a callback": { + topic: function(q) { + var i = 0, + counter = 10, + decr = function(j, cb) { + // do something with j + counter--; + cb(null); + }; + + for (i = 0; i < 100; i++) { + q.enqueue(decr, [i]); + } + + setTimeout(this.callback, 1000); + }, + "it works": function(err) { + assert.ifError(err); + } + } } } }); -suite["export"](module); \ No newline at end of file +suite["export"](module); From 58c07178d395817f91c8b8039946a90a468e5490 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Mon, 9 Oct 2017 11:33:34 -0400 Subject: [PATCH 2/2] Fix package.json license field --- package.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/package.json b/package.json index 952a170..4d81ac3 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,5 @@ "url": "git://github.com/e14n/jankyqueue.git" }, - "licenses": [ - { - "type": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - } - ] + "license": "Apache-2.0" }