UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

48 lines 947 B
//#region src/map/removeOrThrow.d.ts /** * `removeOrThrow(map, key)` * * Removes the entry with the specified `key` from `map`, throwing an error if the key doesn't exist. * * ```ts * removeOrThrow( * new Map([ * ["a", 1], * ["b", 2], * ]), * "a", * ); // Map(1) { "b" => 2 } * * removeOrThrow( * new Map([ * ["a", 1], * ["b", 2], * ]), * "c", * ); // throws FnError * ``` * * ```ts * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * removeOrThrow("a"), * ); // Map(1) { "b" => 2 } * * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * removeOrThrow("c"), * ); // throws FnError * ``` */ declare const removeOrThrow: { <K, V>(key: NoInfer<K>): (target: ReadonlyMap<K, V>) => Map<K, V>; <K, V>(target: ReadonlyMap<K, V>, key: NoInfer<K>): Map<K, V>; }; //#endregion export { removeOrThrow };