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

2.0.3 • Public • Published

@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

Package Sidebar

Install

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

Weekly Downloads

1,360

Version

2.0.3

License

MIT

Unpacked Size

4.72 kB

Total Files

4

Last publish

Collaborators

  • coderaiser