From 5d66b2abcf3e68da1f8d397d44a246f7c562a3da Mon Sep 17 00:00:00 2001 From: Graeme Yeates Date: Sun, 3 Jul 2016 17:57:50 -0400 Subject: Simplify priorityQueue callback checks --- lib/priorityQueue.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') 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) { -- cgit v1.2.1