2.0.3 β€’ Published 1 year ago

@putout/plugin-convert-map-to-for-of v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@putout/plugin-convert-map-to-for-of NPM version

  • The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

  • The for...of statement creates a loop which invokes a custom iteration hook with statements to be executed for the value of each element of an array.

(c) MDN

🐊Putout plugin adds ability to convert map to for...of loop. Merged to @putout/plugin-for-of.

Install

npm i @putout/plugin-convert-map-to-for-of -D

Rule

{
    "rules": {
        "convert-map-to-for-of": "on"
    }
}

❌ Example of incorrect code

names.map((name) => {
    alert(`hello ${name}`);
});

βœ… Example of correct code

for (const name of names) {
    alert(`hello ${name}`);
}

License

MIT