UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

26 lines (24 loc) 591 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/set/forEach.ts /** * `forEach(target, fn)` * * Iterates over each value in the `target` set, calling the `fn` function for each value. Returns the original set unchanged. * * ```ts * forEach(new Set([1, 2, 3]), (value) => console.log(value)); // Set([1, 2, 3]) * ``` * * ```ts * pipe( * new Set([1, 2, 3]), * forEach((value) => console.log(value)), * ); // Set([1, 2, 3]) * ``` */ const forEach = dfdlT((target, fn) => { for (const value of target) fn(value, target); return target; }, 2); //#endregion export { forEach };