import { insert } from "https://deno.land/x/upsert@1.2.0/emplace.ts";
Add the entry if the key does not exist.
Examples
Example 1
Example 1
import { insert } from "https://deno.land/x/upsert/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const key: string;
declare const value: number;
const map = new Map<typeof key, typeof value>();
insert(map, key, () => value);
assertEquals(map, new Map([[key, value]]));