//#region src/Map/mapOrThrow.d.ts /** * # mapOrThrow * * ```ts * function Map.mapOrThrow( * target: ReadonlyMap, * key: NoInfer, * transform: ( * value: NoInfer, * key: NoInfer, * target: ReadonlyMap, * ) => V, * ): ReadonlyMap * ``` * * Transforms the value at the specified key using the provided function, or throws an error if the key doesn't exist. * * ## Example * * ```ts [data-first] * import { Map } from "@monstermann/map"; * * Map.mapOrThrow( * new Map([ * ["a", 1], * ["b", 2], * ]), * "a", * (value) => value * 2, * ); // Map(2) { "a" => 2, "b" => 2 } * * Map.mapOrThrow( * new Map([ * ["a", 1], * ["b", 2], * ]), * "c", * (value) => value * 2, * ); // throws FnError * ``` * * ```ts [data-last] * import { Map } from "@monstermann/map"; * * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * Map.mapOrThrow("a", (value) => value * 2), * ); // Map(2) { "a" => 2, "b" => 2 } * * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * Map.mapOrThrow("c", (value) => value * 2), * ); // throws FnError * ``` * */ declare const mapOrThrow: { (key: NoInfer, transform: (value: NoInfer, key: NoInfer, target: ReadonlyMap) => V): (target: Map) => Map; (key: NoInfer, transform: (value: NoInfer, key: NoInfer, target: ReadonlyMap) => V): (target: ReadonlyMap) => ReadonlyMap; (target: Map, key: NoInfer, transform: (value: NoInfer, key: NoInfer, target: ReadonlyMap) => V): Map; (target: ReadonlyMap, key: NoInfer, transform: (value: NoInfer, key: NoInfer, target: ReadonlyMap) => V): ReadonlyMap; }; //#endregion export { mapOrThrow };