UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 756 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/set/isDisjointFrom.ts /** * `isDisjointFrom(target, source)` * * Checks if the `target` set is disjoint from the `source` set (i.e., they share no common values). Returns `true` if the sets have no intersection, `false` otherwise. * * ```ts * isDisjointFrom(new Set([1, 2]), new Set([3, 4])); // true * isDisjointFrom(new Set([1, 2]), new Set([2, 3])); // false * ``` * * ```ts * pipe(new Set([1, 2]), isDisjointFrom(new Set([3, 4]))); // true * pipe(new Set([1, 2]), isDisjointFrom(new Set([2, 3]))); // false * ``` */ const isDisjointFrom = dfdlT((target, source) => { for (const value of target) if (source.has(value)) return false; return true; }, 2); //#endregion export { isDisjointFrom };