@monstermann/fn
Version:
A utility library for TypeScript.
26 lines (24 loc) • 522 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/array/forEach.ts
/**
* `forEach(array, callback)`
*
* Executes the provided `callback` function once for each element in `array` and returns the original array.
*
* ```ts
* forEach([1, 2, 3], (x) => console.log(x)); // [1, 2, 3]
* ```
*
* ```ts
* pipe(
* [1, 2, 3],
* forEach((x) => console.log(x)),
* ); // [1, 2, 3]
* ```
*/
const forEach = dfdlT((target, callback) => {
target.forEach(callback);
return target;
}, 2);
//#endregion
export { forEach };