function queue<TValue>(options): (item, position) => boolean
function queue<TValue>(options): (item, position) => boolean
Defined in: queuer.ts:373
Creates a queuer that processes items in a queuer immediately upon addition. Items are processed sequentially in FIFO order by default.
This is a simplified wrapper around the Queuer class that only exposes the addItem method. For more control over queuer processing, use the Queuer class directly which provides methods like start, stop, reset, and more.
• TValue
QueuerOptions<TValue> = {}
Function
Adds an item to the queuer and starts processing if not already running
TValue
QueuePosition = 'back'
boolean
true if item was added, false if queuer is full
// Basic sequential processing
const processItems = queuer<number>({
wait: 1000,
onUpdate: (queuer) => console.log(queuer.getAllItems())
})
processItems(1) // Logs: 1
processItems(2) // Logs: 2 after 1 completes
// Priority queuer
const processPriority = queuer<number>({
process: async (n) => console.log(n),
getPriority: n => n // Higher numbers processed first
})
processPriority(1)
processPriority(3) // Processed before 1
// Basic sequential processing
const processItems = queuer<number>({
wait: 1000,
onUpdate: (queuer) => console.log(queuer.getAllItems())
})
processItems(1) // Logs: 1
processItems(2) // Logs: 2 after 1 completes
// Priority queuer
const processPriority = queuer<number>({
process: async (n) => console.log(n),
getPriority: n => n // Higher numbers processed first
})
processPriority(1)
processPriority(3) // Processed before 1
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.