Skip to main content
Module

x/bettermap/mod.ts>BetterMap#map

An extension of the Map class with more Array-like features.
Latest
method BetterMap.prototype.map
import { BetterMap } from "https://deno.land/x/bettermap@v1.3.0/mod.ts";

Map the Map into an Array.

const map = new BetterMap<string, number>("People");
map.set("Doraemon", 10);
map.set("Dora", 28);
console.log(map.map(v => v - 10)); // [0, 18]
console.log(map.every((v, k) => k+v))); // ["Doraemon10", "Dora28"]

Parameters

fn: (v: V, k: K) => T

Function for mapping.

Returns

T[] | []

Array.