UNPKG

@jaenster/queues

Version:
18 lines (15 loc) 465 B
import {FiFo} from "../queue/fi-fo.js"; import {Work} from "./work.js"; export class BurstQueue<T> extends FiFo<T> { private isSet: number = 0; constructor(private readonly cb: (args: BurstQueue<T>) => any) { super(() => { if (++this.isSet === 1) Work.queue.add({ work: () => { this.isSet = 0; this.cb(this); } }); }) } }