UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

35 lines (33 loc) 652 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/map/forEach.ts /** * `forEach(map, fn)` * * Executes `fn` for each entry in `map` and returns the original map. * * ```ts * forEach( * new Map([ * ["a", 1], * ["b", 2], * ]), * (value, key) => console.log(key, value), * ); // Map(2) { "a" => 1, "b" => 2 } * ``` * * ```ts * pipe( * new Map([ * ["a", 1], * ["b", 2], * ]), * forEach((value, key) => console.log(key, value)), * ); // Map(2) { "a" => 1, "b" => 2 } * ``` */ const forEach = dfdlT((target, fn) => { target.forEach(fn); return target; }, 2); //#endregion export { forEach };