@monstermann/fn
Version:
A utility library for TypeScript.
23 lines (21 loc) • 532 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/array/hasAny.ts
/**
* `hasAny(array, values)`
*
* Returns `true` if `array` contains any of the `values`, otherwise returns `false`. Supports iterables for the `values` parameter.
*
* ```ts
* hasAny([1, 2, 3, 4], [5, 6, 2]); // true
* ```
*
* ```ts
* pipe([1, 2, 3, 4], hasAny([5, 6, 2])); // true
* ```
*/
const hasAny = dfdlT((target, values) => {
for (const value of values) if (target.includes(value)) return true;
return false;
}, 2);
//#endregion
export { hasAny };