@monstermann/fn
Version:
A utility library for TypeScript.
51 lines (49 loc) • 834 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/map/hasNone.ts
/**
* `hasNone(map, keys)`
*
* Checks if `map` contains none of the specified `keys`. This function supports iterables.
*
* ```ts
* hasNone(
* new Map([
* ["a", 1],
* ["b", 2],
* ]),
* ["c", "d"],
* ); // true
*
* hasNone(
* new Map([
* ["a", 1],
* ["b", 2],
* ]),
* ["a", "c"],
* ); // false
* ```
*
* ```ts
* pipe(
* new Map([
* ["a", 1],
* ["b", 2],
* ]),
* hasNone(["c", "d"]),
* ); // true
*
* pipe(
* new Map([
* ["a", 1],
* ["b", 2],
* ]),
* hasNone(["a", "c"]),
* ); // false
* ```
*/
const hasNone = dfdlT((target, keys) => {
for (const key of keys) if (target.has(key)) return false;
return true;
}, 2);
//#endregion
export { hasNone };