Skip to main content
Module

x/bettermap/mod.ts>BetterMap#reduce

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

Reduce data in the map.

const map = new BetterMap<string, number>("People");
map.set("Doraemon", 10);
map.set("Dora", 28);
console.log(map.reduce((acc, val) => acc + (val[1] > 10 ? "a" : "b") + val[0], ""));
// bDoraemonaDora

Parameters

fn: (acc: T, val: [K, V]) => T

Reducer function.

first: T

Returns

Reduced data.