## Classes
EventEmitterChannel class (queue)
EventEmitterChannelQueue class, for managing channels
ChannelParallelChannel class (queue)
Internal Task class, for handling executions
Normal | High | TailTask Priority
EventEmitter
ChannelQueue class, for managing channels
**Kind**: global class
**Extends**: EventEmitter
* [ChannelQueue](#ChannelQueue) ⇐ EventEmitter
* [.channels](#ChannelQueue+channels) : Object
* [.createChannel(name)](#ChannelQueue+createChannel) ⇒ [Channel](#Channel)
* [.createParallelChannel(name, [parallelism])](#ChannelQueue+createParallelChannel) ⇒ [ParallelChannel](#ParallelChannel)
* [.channel(name)](#ChannelQueue+channel) ⇒ [Channel](#Channel)
* [.channelExists(name)](#ChannelQueue+channelExists) ⇒ Boolean
### channelQueue.channels : Object
The channels
**Kind**: instance property of [ChannelQueue](#ChannelQueue)
### channelQueue.createChannel(name) ⇒ [Channel](#Channel)
Create a new channel
**Kind**: instance method of [ChannelQueue](#ChannelQueue)
**Returns**: [Channel](#Channel) - The new channel
**Throws**:
- Error Throws if the channel already exists
| Param | Type | Description |
| --- | --- | --- |
| name | String | The channel name |
### channelQueue.createParallelChannel(name, [parallelism]) ⇒ [ParallelChannel](#ParallelChannel)
Create a new parallel channel
Creates a special channel that supports running several tasks in parallel.
**Kind**: instance method of [ChannelQueue](#ChannelQueue)
**Returns**: [ParallelChannel](#ParallelChannel) - The new channel
**Throws**:
- Error Throws if the channel already exists
| Param | Type | Description |
| --- | --- | --- |
| name | String | The name of the channel |
| [parallelism] | Number | Optional number of maximum parallel tasks |
### channelQueue.channel(name) ⇒ [Channel](#Channel)
Get channel by name
Creates a new channel automatically if it doesn't yet exist
**Kind**: instance method of [ChannelQueue](#ChannelQueue)
**Returns**: [Channel](#Channel) - The channel which was requested
| Param | Type | Description |
| --- | --- | --- |
| name | String | The channel name |
### channelQueue.channelExists(name) ⇒ Boolean
Check if a channel exists
**Kind**: instance method of [ChannelQueue](#ChannelQueue)
**Returns**: Boolean - True if it exists
| Param | Type | Description |
| --- | --- | --- |
| name | String | The name of the channel |
## ParallelChannel ⇐ [Channel](#Channel)
ParallelChannel class (queue)
**Kind**: global class
**Extends**: [Channel](#Channel)
* [ParallelChannel](#ParallelChannel) ⇐ [Channel](#Channel)
* [.isEmpty](#ParallelChannel+isEmpty) : Boolean
* [.parallelism](#ParallelChannel+parallelism) : Number
* [.runningTasks](#ParallelChannel+runningTasks) : [Array.<Task>](#Task)
* [.autostart](#Channel+autostart) : Boolean
* [.isRunning](#Channel+isRunning) : Boolean
* [.name](#Channel+name) : String
* [.tasks](#Channel+tasks) : [Array.<Task>](#Task)
* [.tasksThrow](#Channel+tasksThrow) : Boolean
* [.clear([priorityType])](#Channel+clear)
* [.enqueue(item, [type], [stack], [timeout])](#Channel+enqueue) ⇒ Promise
* [.getStackedItems(stack)](#Channel+getStackedItems) ⇒ [Array.<Task>](#Task)
* [.retrieveNextItem()](#Channel+retrieveNextItem) ⇒ [Task](#Task) \| undefined
* [.sort()](#Channel+sort)
* [.start()](#Channel+start) ⇒ Boolean
* [.waitForEmpty()](#Channel+waitForEmpty) ⇒ Promise
### parallelChannel.isEmpty : Boolean
Whether the queue is empty or not
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [isEmpty](#Channel+isEmpty)
**Read only**: true
### parallelChannel.parallelism : Number
The amount of allowed parallel executed tasks
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Read only**: true
### parallelChannel.runningTasks : [Array.<Task>](#Task)
Get the currently running tasks
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Read only**: true
### parallelChannel.autostart : Boolean
Whether the execution should start automatically or not
Defaults to true
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [autostart](#Channel+autostart)
### parallelChannel.isRunning : Boolean
Whether the queue is currently running or not
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [isRunning](#Channel+isRunning)
**Read only**: true
### parallelChannel.name : String
The name of the channel
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [name](#Channel+name)
**Read only**: true
### parallelChannel.tasks : [Array.<Task>](#Task)
Array of tasks (in queue)
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [tasks](#Channel+tasks)
**Read only**: true
### parallelChannel.tasksThrow : Boolean
Whether or not tasks throw errors
**Kind**: instance property of [ParallelChannel](#ParallelChannel)
**Overrides**: [tasksThrow](#Channel+tasksThrow)
### parallelChannel.clear([priorityType])
Remove all pending tasks from the channel
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [clear](#Channel+clear)
| Param | Type | Description |
| --- | --- | --- |
| [priorityType] | String | Optional priority type to clear only tasks with a certain priority value |
### parallelChannel.enqueue(item, [type], [stack], [timeout]) ⇒ Promise
Enqueues a function
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [enqueue](#Channel+enqueue)
**Returns**: Promise - A promise that eventually resolves with the result from the
enqueued function or promise
| Param | Type | Description |
| --- | --- | --- |
| item | function \| Promise | The item to place into the queue |
| [type] | [TaskPriority](#TaskPriority) | The task priority to use |
| [stack] | String | The stack name |
| [timeout] | Number | Optional millisecond time-limt |
### parallelChannel.getStackedItems(stack) ⇒ [Array.<Task>](#Task)
Get all task items for a stack name
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [getStackedItems](#Channel+getStackedItems)
**Returns**: [Array.<Task>](#Task) - An array of task instances
| Param | Type | Description |
| --- | --- | --- |
| stack | String | The stack name |
### parallelChannel.retrieveNextItem() ⇒ [Task](#Task) \| undefined
Get the next queued Task instance
This modifies the task queue by removing the task
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [retrieveNextItem](#Channel+retrieveNextItem)
**Returns**: [Task](#Task) \| undefined - A task instance if there are any in queue
### parallelChannel.sort()
Sort the tasks
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [sort](#Channel+sort)
### parallelChannel.start() ⇒ Boolean
Start processing the queue
Will automatically return early if queue has already started
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [start](#Channel+start)
**Returns**: Boolean - Returns true if started, false if already started
**Emits**: Channel#event:started, Channel#event:stopped
### parallelChannel.waitForEmpty() ⇒ Promise
Wait for the queue to become empty
**Kind**: instance method of [ParallelChannel](#ParallelChannel)
**Overrides**: [waitForEmpty](#Channel+waitForEmpty)
## Task
Internal Task class, for handling executions
**Kind**: global class
* [Task](#Task)
* [new Task(item, [type], [stack])](#new_Task_new)
* [.created](#Task+created) : Number
* [.error](#Task+error) : Error \| null
* [.queuedPromise](#Task+queuedPromise) : Promise
* [.stack](#Task+stack) : String
* [.target](#Task+target) : function
* [.timeLimit](#Task+timeLimit) : Number
* [.type](#Task+type) : [TaskPriority](#TaskPriority)
* [.execute()](#Task+execute) ⇒ Promise
### new Task(item, [type], [stack])
Constructor for a Task
| Param | Type | Description |
| --- | --- | --- |
| item | function \| Promise | The item to enqueue |
| [type] | [TaskPriority](#TaskPriority) | The priority to set |
| [stack] | String | The stack name |
### task.created : Number
Creation timestamp
**Kind**: instance property of [Task](#Task)
**Read only**: true
### task.error : Error \| null
Execution error, if one occurred
**Kind**: instance property of [Task](#Task)
### task.queuedPromise : Promise
Promise which resolves when work has completed
**Kind**: instance property of [Task](#Task)
### task.stack : String
The stack name
**Kind**: instance property of [Task](#Task)
### task.target : function
The target function
**Kind**: instance property of [Task](#Task)
### task.timeLimit : Number
Current time limit
**Kind**: instance property of [Task](#Task)
### task.type : [TaskPriority](#TaskPriority)
The task priority type
**Kind**: instance property of [Task](#Task)
### task.execute() ⇒ Promise
Execute the task
**Kind**: instance method of [Task](#Task)
## TaskPriority : [Normal](#TaskPriority.Normal) \| [High](#TaskPriority.High) \| [Tail](#TaskPriority.Tail)
Task Priority
**Kind**: global typedef
* [TaskPriority](#TaskPriority) : [Normal](#TaskPriority.Normal) \| [High](#TaskPriority.High) \| [Tail](#TaskPriority.Tail)
* [.Normal](#TaskPriority.Normal)
* [.High](#TaskPriority.High)
* [.Tail](#TaskPriority.Tail)
### TaskPriority.Normal
Normal task priority
**Kind**: static property of [TaskPriority](#TaskPriority)
### TaskPriority.High
High task priority
**Kind**: static property of [TaskPriority](#TaskPriority)
### TaskPriority.Tail
Task tail-priority
**Kind**: static property of [TaskPriority](#TaskPriority)