8.1.1 β’ Published 1 year ago
@putout/plugin-convert-for-each-to-for-of v8.1.1
@putout/plugin-convert-for-each-to-for-of
The
forEach()
method executes a provided function once for each array element.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 forEach()
to for...of
.
Complements @putout/plugin-convert-const-to-let
. Merged to @putout/plugin-for-of
.
Install
npm i @putout/plugin-convert-for-each-to-for-of -D
Rule
{
"rules": {
"convert-for-each-to-for-of": "on"
}
}
β Example of incorrect code
Object.keys(json).forEach((name) => {
manage(name, json[name]);
});
[].forEach.call(arguments, (item) => {
console.log(item);
});
β Example of correct code
for (const name of Object.keys(json)) {
manage(name, json[name]);
}
for (const name of arguments) {
console.log(item);
}
License
MIT
8.1.1
1 year ago
8.1.0
1 year ago
8.0.0
1 year ago
7.1.2
2 years ago
7.1.1
2 years ago
7.1.0
2 years ago
7.0.0
2 years ago
6.1.0
3 years ago
6.2.0
3 years ago
6.0.0
3 years ago
5.2.0
4 years ago
5.1.0
4 years ago
5.0.0
4 years ago
4.0.0
4 years ago
3.0.0
4 years ago
2.1.0
5 years ago
2.0.0
5 years ago
1.5.3
5 years ago
1.5.2
5 years ago
1.5.1
5 years ago
1.5.0
5 years ago
1.4.0
5 years ago
1.3.1
5 years ago
1.3.0
5 years ago
1.2.0
5 years ago
1.1.0
5 years ago
1.0.0
5 years ago