2.0.3 β’ Published 3 years ago
@putout/plugin-convert-map-to-for-of v2.0.3
@putout/plugin-convert-map-to-for-of 
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...ofstatement 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 -DRule
{
"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