UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 642 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/set/hasAll.ts /** * `hasAll(target, values)` * * Checks if the `target` set contains all of the specified `values` from an iterable. Returns `true` if all values exist, `false` otherwise. * * ```ts * hasAll(new Set([1, 2, 3]), [1, 2]); // true * hasAll(new Set([1, 2, 3]), [1, 4]); // false * ``` * * ```ts * pipe(new Set([1, 2, 3]), hasAll([1, 2])); // true * pipe(new Set([1, 2, 3]), hasAll([1, 4])); // false * ``` */ const hasAll = dfdlT((target, values) => { for (const value of values) if (!target.has(value)) return false; return true; }, 2); //#endregion export { hasAll };