UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

53 lines (51 loc) 1.12 kB
import { OrElse } from "./internals/types.js"; //#region src/map/removeOrElse.d.ts /** * `removeOrElse(map, key, orElse)` * * Removes the entry with the specified `key` from `map`, calling `orElse` with the map if the key doesn't exist. * * ```ts * removeOrElse( * new Map([ * ["a", 1], * ["b", 2], * ]), * "a", * () => null, * ); // Map(1) { "b" => 2 } * * removeOrElse( * new Map([ * ["a", 1], * ["b", 2], * ]), * "c", * (map) => map.size, * ); // 2 * ``` * * ```ts * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * removeOrElse("a", () => null), * ); // Map(1) { "b" => 2 } * * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * removeOrElse("c", (map) => map.size), * ); // 2 * ``` */ declare const removeOrElse: { <K, V, U>(key: NoInfer<K>, orElse: OrElse<K, V, U>): (target: ReadonlyMap<K, V>) => Map<K, V> | U; <K, V, U>(target: ReadonlyMap<K, V>, key: NoInfer<K>, orElse: OrElse<K, V, U>): Map<K, V> | U; }; //#endregion export { removeOrElse };