repos / starfx

supercharged async flow control library.
git clone https://github.com/neurosnap/starfx.git

Eric Bower · 10 Nov 23

queue.ts

 1import { createQueue } from "./deps.ts";
 2
 3export function createFilterQueue<T, TClose>(predicate: (v: T) => boolean) {
 4  const queue = createQueue<T, TClose>();
 5
 6  return {
 7    ...queue,
 8    add(value: T) {
 9      if (predicate(value)) {
10        queue.add(value);
11      }
12    },
13  };
14}