Global

Methods

end(hash)

Signal that the task `hash` has finished.
Frees its slot in the queue
Parameters:
Name Type Description
hash any Unique hash identifying the task, Symbol() works very well
Source:

flush() → {Promise.<void>}

Returns a promise that resolves when the queue is empty
Source:
Returns:
Type
Promise.<void>

run(job, priorityopt) → {Promise.<any>}

Run a job (equivalent to calling Queue.wait(), fn() and then Queue.end())
fn can be both synchronous or asynchronous function
Parameters:
Name Type Attributes Default Description
job function The job
priority number <optional>
0 Optional priority, -1 is higher priority than 1
Source:
Returns:
Resolved when the task has finished with the return value of fn
Type
Promise.<any>

stat() → {QueueStats}

Return the number of running and waiting jobs
Source:
Returns:
running, waiting, last
Type
QueueStats

wait(hash, priorityopt) → {Promise.<void>}

Wait for a slot in the queue
Parameters:
Name Type Attributes Default Description
hash any Unique hash identifying the task
priority number <optional>
0 Optional priority, -1 is higher priority than 1
Source:
Returns:
Resolved when the task is ready to run
Type
Promise.<void>