Skip to content

Commit

Permalink
Expose paused status flag (#91)
Browse files Browse the repository at this point in the history
* Expose paused status flag

* Fix legacy tests
  • Loading branch information
greguz authored Jan 30, 2025
1 parent 571b25b commit 45c6b3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ each time a task is completed, `err` will be not null if the task has thrown an
Property that returns the number of concurrent tasks that could be executed in
parallel. It can be altered at runtime.

-------------------------------------------------------
<a name="paused"></a>
### queue.paused

Property (Read-Only) that returns `true` when the queue is in a paused state.

-------------------------------------------------------
<a name="drain"></a>
### queue.drain
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare namespace fastq {
killAndDrain(): any
error(handler: errorHandler<T>): void
concurrency: number
readonly paused: boolean
drain(): any
empty: () => void
saturated: () => void
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,14 @@ test('pause/resume should trigger drain event', function (t) {

queue.resume()
})

test('paused flag', function (t) {
t.plan(2)

var queue = buildQueue(function (arg, cb) {
cb(null)
}, 1)
t.equal(queue.paused, false)
queue.pause()
t.equal(queue.paused, true)
})

0 comments on commit 45c6b3c

Please sign in to comment.