UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

23 lines (21 loc) 502 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/string/hasAny.ts /** * `hasAny(target, source)` * * Checks if `target` string contains any of the strings from the `source` iterable. * * ```ts * hasAny("hello world", ["foo", "world"]); // true * ``` * * ```ts * pipe("hello world", hasAny(["foo", "world"])); // true * ``` */ const hasAny = dfdlT((target, source) => { for (const value of source) if (target.includes(value)) return true; return false; }, 2); //#endregion export { hasAny };