## Executor

Executes operations sequentially. Has an option for a buffer that can be triggered afterwards.

**Kind**: global class * [Executor](#Executor) * [new Executor()](#new_Executor_new) * [.ready](#Executor+ready) : boolean * [.queue](#Executor+queue) : [Waterfall](#Waterfall) * [.buffer](#Executor+buffer) : [Waterfall](#Waterfall) * [._triggerBuffer()](#Executor+_triggerBuffer) * [.push(task, [forceQueuing])](#Executor+push) * [.pushAsync(task, [forceQueuing])](#Executor+pushAsync) ⇒ Promise.<\*> * [.processBuffer()](#Executor+processBuffer) ### new Executor()

Instantiates a new Executor.

### executor.ready : boolean

If this.ready is false, then every task pushed will be buffered until this.processBuffer is called.

**Kind**: instance property of [Executor](#Executor) **Access**: protected ### executor.queue : [Waterfall](#Waterfall)

The main queue

**Kind**: instance property of [Executor](#Executor) **Access**: protected ### executor.buffer : [Waterfall](#Waterfall)

The buffer queue

**Kind**: instance property of [Executor](#Executor) **Access**: protected ### executor.\_triggerBuffer()

Method to trigger the buffer processing.

Do not be use directly, use this.processBuffer instead.

**Kind**: instance method of [Executor](#Executor) **Access**: protected ### executor.push(task, [forceQueuing])

If executor is ready, queue task (and process it immediately if executor was idle) If not, buffer task for later processing

**Kind**: instance method of [Executor](#Executor) | Param | Type | Default | Description | | --- | --- | --- | --- | | task | Object | | | | task.this | Object | |

Object to use as this

| | task.fn | function | |

Function to execute

| | task.arguments | Array | |

Array of arguments, IMPORTANT: only the last argument may be a function (the callback) and the last argument cannot be false/undefined/null

| | [forceQueuing] | Boolean | false |

Optional (defaults to false) force executor to queue task even if it is not ready

| ### executor.pushAsync(task, [forceQueuing]) ⇒ Promise.<\*>

If executor is ready, queue task (and process it immediately if executor was idle) If not, buffer task for later processing

**Kind**: instance method of [Executor](#Executor) | Param | Type | Default | | --- | --- | --- | | task | function | | | [forceQueuing] | boolean | false | ### executor.processBuffer()

Queue all tasks in buffer (in the same order they came in) Automatically sets executor as ready

**Kind**: instance method of [Executor](#Executor)