add(...tasks)
Validates every argument, appends them in order, and starts the queue when eligible.
- Accepts
- Zero or more functions
- Returns
- The queue instance
- Throws
TypeErrorif any value is not a function; nothing is appended from that call
Complete surface
Three methods coordinate work. Four state properties expose and control the queue.
Methods
Methods live on Queue.prototype. Every task is called with the queue instance as this.
Validates every argument, appends them in order, and starts the queue when eligible.
TypeError if any value is not a function; nothing is appended from that callRuns and removes the first pending task unless stop is true. Calling it on an empty queue settles the queue as idle.
undefinedrunningReplaces pending contents with a new empty array. The currently executing task continues.
size becomes 0Creates an idle queue with automatic start enabled and execution unblocked.
truefalsefalse0State
size and running are read-only getters. autoRun, stop, and contents are intentionally writable control surfaces.
| Member | Default | Writable | Meaning |
|---|---|---|---|
contents | [] | Yes | The actual pending function array. Replacement validates the complete array. |
size | 0 | No | The current pending item count; it excludes the active task. |
running | false | No | Whether a task currently owns execution. |
autoRun | true | Yes | Whether an eligible add() starts the front task. |
stop | false | Yes | Whether next() should hold pending work. |
stop=false does not start work by itself.After opening a stop gate, call next() to resume existing pending work. A later add() can also start an idle queue when autoRun is true.
See these members composed into connection gates and recovery flows.
Open patterns