description: "Circular deque for Host and browser packages that need amortized constant-time queue operations, immediate release of removed entries, and bounded vacant storage."
English | 中文
dsh-deque lets Host and browser packages drain long-lived in-process queues without moving every remaining entry after each removal. Callers append or prepend entries and remove them from the front with amortized constant-time operations. The deque owns entry order and backing-storage release; each consumer still owns wake-up, failure, cancellation, capacity, and overload behavior.
Use Deque<T> when entries can accumulate across asynchronous work and the consumer needs FIFO removal, optional front insertion, or explicit queue clearing. Finite local worklists can stay as arrays when their maximum size makes head removal cost irrelevant.
Import the deque, append entries at the tail, and check size before removing an entry whose type may include undefined:
import { Deque } from '@deepseek-ai/dsh-deque'
const frames = new Deque<string>()
frames.pushBack('first')
frames.pushFront('before-first')
while (frames.size > 0) {
console.log(frames.popFront())
}
The methods do not impose a queue limit or translate consumer failures. See src/index.ts for the exact TypeScript contract.
None, as this in-process collection registers nothing model-facing.
Nothing here enters a model request, so provider cache reuse is unaffected.