Queue

Methods

# add(element)

Adds an element to the end of the queue.

Parameters:
Name Type Description
element any

The element to add

Since:
  • 1.0.0

# empty() → {boolean}

Returns whether the queue is currently empty

Since:
  • 1.0.0
Returns:
Type
boolean

# first() → {any|null}

Returns the first element in the queue or null if it is empty.

Since:
  • 1.0.0
Returns:
Type
any | null

# get(index) → {any|null}

Returns the element with the given index or null if nothing was found.

You can also pass a negative number to start counting from the end. E.g. -1 will return the last element.

Parameters:
Name Type Description
index number

The index of the element you want to return.

Since:
  • 1.0.0
Returns:
Type
any | null

# indexLength() → {number}

Returns the zero-based length for array operations. An empty queue still returns 0.

A queue with 4 elements would return 3 as indexLength(), since queue[3] points to the 4th element.

Since:
  • 1.0.0
Returns:
Type
number

# last() → {any|null}

Returns the last element in the queue or null if it is empty.

Since:
  • 1.0.0
Returns:
Type
any | null

# length() → {number}

Returns the amount of elements currently in the queue.

Since:
  • 1.0.0
Returns:
Type
number

# processEach(promiseFunc, delayBetweenopt, resumeSEQueueopt)

Passes the first queue element to the specified function and removes it from the queue after resolving the Promise.

This gets repeated for each element, until the queue is empty.

Parameters:
Name Type Attributes Default Description
promiseFunc function

The function to execute with the first queue element as parameter. This HAS TO return a resolving promise

delayBetween number <optional>
0

Milliseconds to wait between each processing cycle

resumeSEQueue boolean <optional>
false

Determines if SE_API.resumeQueue() should be called after processing each element

Since:
  • 1.0.0

# processFirst(promiseFunc, delayAfteropt, resumeSEQueueopt) → {Promise}

Passes the first queue element to the specified function and removes it from the queue after resolving the Promise.

This function returns a Promise which resolves after the first element is cleared.

Parameters:
Name Type Attributes Default Description
promiseFunc function

The function to execute with the first queue element as parameter. This HAS TO return a resolving promise

delayAfter number <optional>
0

Milliseconds to wait before this function resolves

resumeSEQueue boolean <optional>
false

Determines if SE_API.resumeQueue() should be called after processing the current element

Since:
  • 1.0.0
Returns:
Type
Promise

# ready() → {boolean}

Returns whether the queue is currently usable.

Since:
  • 1.0.0
Returns:
Type
boolean

# remove(index, deleteCountopt)

Removes one or more elements from the queue. Starting with the given index

Parameters:
Name Type Attributes Default Description
index number

The index to start removing elements from

deleteCount number <optional>
1

The number of elements to remove

Since:
  • 1.0.0

# removeFirst()

Removes the first element of the queue

Since:
  • 1.0.0

# removeLast()

Removes the last element of the queue

Since:
  • 1.0.0