fastq
Advanced tools
Comparing version 1.14.0 to 1.15.0
{ | ||
"name": "fastq", | ||
"version": "1.14.0", | ||
"version": "1.15.0", | ||
"description": "Fast, in memory work queue", | ||
@@ -5,0 +5,0 @@ "main": "queue.js", |
@@ -269,2 +269,8 @@ 'use strict' | ||
function drained () { | ||
if (queue.idle()) { | ||
return new Promise(function (resolve) { | ||
resolve() | ||
}) | ||
} | ||
var previousDrain = queue.drain | ||
@@ -271,0 +277,0 @@ |
@@ -132,2 +132,29 @@ 'use strict' | ||
test('drained while idle should resolve', async function (t) { | ||
const queue = buildQueue(worker, 2) | ||
async function worker (arg) { | ||
await sleep(arg) | ||
} | ||
await queue.drained() | ||
}) | ||
test('drained while idle should not call the drain function', async function (t) { | ||
let drainCalled = false | ||
const queue = buildQueue(worker, 2) | ||
queue.drain = function () { | ||
drainCalled = true | ||
} | ||
async function worker (arg) { | ||
await sleep(arg) | ||
} | ||
await queue.drained() | ||
t.equal(drainCalled, false) | ||
}) | ||
test('set this', async function (t) { | ||
@@ -134,0 +161,0 @@ t.plan(1) |
38885
1032