diff options
-rw-r--r-- | lib/priorityQueue.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/priorityQueue.js b/lib/priorityQueue.js index e895d8b..147a009 100644 --- a/lib/priorityQueue.js +++ b/lib/priorityQueue.js @@ -36,7 +36,8 @@ export default function(worker, concurrency) { // Override push to accept second parameter representing priority q.push = function(data, priority, callback) { - if (callback != null && typeof callback !== 'function') { + if (callback == null) callback = noop; + if (typeof callback !== 'function') { throw new Error('task callback must be a function'); } q.started = true; @@ -59,7 +60,7 @@ export default function(worker, concurrency) { var item = { data: task, priority: priority, - callback: typeof callback === 'function' ? callback : noop + callback: callback }; if (nextNode) { |