UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

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