ez-each
v1.0.2
Published
Replacement for JavaScript's forEach implementation; synchronous & compatible with TypeScript
Downloads
17
Maintainers
Readme
Array.ezEach
Replacement for JavaScript's forEach implementation; synchronous & compatible with TypeScript
Installation
npm i ez-eachFor NPM version < 5
npm install ez-each --saveUsage
Traditional forEach
["a", "b", "c"].forEach((letter: string) => console.log(letter));Output:
a
b
cThe order of the output is potentially random as it depends on each item's individual iteration time.
Traditional forEach replacement (for loop)
let array = ["a", "b", "c"];
for (let index = 0; index < array.length; index++)
console.log(array[index]);Output:
a
b
cUsing ezEach
Import the library just once, at a central place in your code if possible.
import "ez-each";
["a", "b", "c"].ezEach((letter: string) => console.log(letter));Output:
a
b
cComparison
Function | Synchronous | Easy Syntax | |----------------|---------------|---------------| | Array.forEach()| [ ] no | [x] yes | | for loop | [x] yes| [ ] no | | Array.ezEach() | [X] yes| [x] yes |
