diff options
author | Alex Early <alexander.early@gmail.com> | 2018-09-30 17:00:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-30 17:00:10 -0700 |
commit | 8aecf108b3922bc5211036706a0f6f75e02bd42b (patch) | |
tree | 0f7b6bee315231ef4aefdfbee154822921de231f /lib/priorityQueue.js | |
parent | df41256f49c9bb3126e035c95aca7860329b6acf (diff) | |
download | async-8aecf108b3922bc5211036706a0f6f75e02bd42b.tar.gz |
feat: await-able Async methods (#1572)
* make each and family awaitable
* dont pretend they're AsyncFunctions
* check errors
* ensure function name is preserved somehow
* awaitable concat
* awaitable detect
* awaitable every/filter
* awaitable groupBy
* awaitable map/mapValues
* awaitable reduce
* awaitable reject
* awaitable some
* awaitable transform
* awaitable times
* awaitable auto
* awaitable compose/seq
* awaitable whilst/until (lol)
* awaitable forever
* awaitable parallel/race
* awaitable retry
* awaitable series (lol)
* awaitable tryEach
* awaitable waterfall (lol)
* lint
* cleanup, remove noop and unused internal functions
Diffstat (limited to 'lib/priorityQueue.js')
-rw-r--r-- | lib/priorityQueue.js | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/lib/priorityQueue.js b/lib/priorityQueue.js index aa9b578..4eaea38 100644 --- a/lib/priorityQueue.js +++ b/lib/priorityQueue.js @@ -1,7 +1,4 @@ -import noop from './internal/noop'; - import setImmediate from './setImmediate'; - import queue from './queue'; /** @@ -32,8 +29,7 @@ export default function(worker, concurrency) { var q = queue(worker, concurrency); // Override push to accept second parameter representing priority - q.push = function(data, priority, callback) { - if (callback == null) callback = noop; + q.push = function(data, priority = 0, callback = () => {}) { if (typeof callback !== 'function') { throw new Error('task callback must be a function'); } @@ -46,7 +42,6 @@ export default function(worker, concurrency) { return setImmediate(() => q.drain()); } - priority = priority || 0; var nextNode = q._tasks.head; while (nextNode && priority >= nextNode.priority) { nextNode = nextNode.next; |