Queue
Provides queuing and dequeing of any type of data. Uses the First In, First Out (FIFO) method. rejectIfExists only logs the error, but allows the program to continue to run without throwing an error.
JLS.loaders.Queue
new Queue(rejectIfExists)
// Implementation example
import { Queue } from 'path/to/loaders'
const data = // some data with type of {any}
const dataQ = new Queue({
rejectIfExists: true,
})
// Placing in queue
dataQ.enqueue(data)
// Retrieval of the data from the queue
let someVariable = dataQ.dequeue()
options
The word "options" is used somewhat loosely here as most of the fields are required. Actual optional parameters will have an optional flag.
| Name | Type | Default | Description |
|---|---|---|---|
| rejectIfExists | boolean | true | optional Log an error if the data already exists in the queue. Doesn't actually reject, only logs an error. |
Members
rejectIfExists
Whether or not to log and error if data that is being added already exists in the queue.
data
An array that holds all the data in queue.
Methods
length()
Retrieves the amount of data data remaining.
isEmpty()
Returns whether or not queue is empty.
peek()
Retrieves the first item in the queue without removing it.
enqueue()
Adds data to the queue.
dequeue()
Removes data from the queue.