{ } qjs-modules

queue

Source: quickjs-queue.c — module export: Queue

A chunked byte queue (FIFO buffer of binary data), iterable over its chunks.

Constructor

new Queue()   // length 1

Methods

MethodArgsDescription
write(data)1Appends data (string/ArrayBuffer/typed array) to the tail.
read(size)1Removes and returns up to size bytes from the head.
peek(size)1Returns up to size bytes from the head without consuming them.
skip(size)1Discards up to size bytes from the head.
clear()0Empties the queue.
next()0Returns the next chunk (iterator step).
chunk(index)1Returns a specific buffered chunk.
at(index)1Returns the byte/chunk at index.
[Symbol.iterator]()0Iterates over the queued chunks.

Properties (read-only)

PropertyDescription
sizeTotal number of buffered bytes.
emptyWhether the queue holds no data.
headThe head chunk.
tailThe tail chunk.
chunksThe list of buffered chunks.

QueueIterator

Returned by [Symbol.iterator]. Exposes next() and tags itself "QueueIterator".