for-each

A better forEach

  • Types
  • ESM
  • CJS
License
MIT
Install Size
23.9 kB(52.9 kB)
Vulns
0
Published

Get started

$npm install for-each
$pnpm add for-each
$yarn add for-each
$bun add for-each
$deno add npm:for-each
$vlt install for-each
$vp add for-each

You might not need this dependency.

This package can be replaced with for...of (using Object.entries if dealing with objects), available since Node 0.12.0.Learn more

Weekly DownloadsAcross all versions

Node.js
>= 0.4

Versions

View all versions
0.3.5
latest

Readme

for-each build status

browser support

A better forEach.

Example

Like Array.prototype.forEach but works on objects.

var forEach = require("for-each")

forEach({ key: "value" }, function (value, key, object) {
    /* code */
})

As a bonus, it's also a perfectly function shim/polyfill for arrays too!

var forEach = require("for-each")

forEach([1, 2, 3], function (value, index, array) {
    /* code */
})

Installation

npm install for-each

MIT Licenced