import { Pipe } from "../pipe.js"; import { assertSync, Yield } from "../util/index.js"; export function isSupersetOf(source: Iterable): Pipe { assertSync(source); return () => { let sourceSet: Set = source instanceof Set ? source : new Set(source); let found: number = 0; return (result: IteratorResult): Array> => { if (result?.done) { return found === sourceSet.size ? [Yield(true), result] : [Yield(false), result]; } if (sourceSet.has(result.value)) { ++found; } }; } }