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