
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@putout/plugin-for-of
Advanced tools
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 support of transformation for...of statements.
npm i @putout/plugin-for-of
{
"rules": {
"for-of/add-missing-declaration": "on",
"for-of/map": "on",
"for-of/for-in": "on",
"for-of/for-each": "on",
"for-of/reduce": "on",
"for-of/remove-unused-variables": "on",
"for-of/remove-useless": "on",
"for-of/remove-useless-array-from": "on",
"for-of/remove-useless-variables": ["on", {
"maxProperties": 4
}],
"for-of/for": "on",
"for-of/to-for-n": "on"
}
}
The
constdeclaration declares block-scoped local variables.(c) MDN
Checkout in πPutout Editor.
for (name of names) {
alert(`hello ${name}`);
}
for (const name of names) {
alert(`hello ${name}`);
}
The
map()method creates a new array populated with the results of calling a provided function on every element in the calling array.(c) MDN
names.map((name) => {
alert(`hello ${name}`);
});
for (const name of names) {
alert(`hello ${name}`);
}
The
for...instatement iterates over all enumerable properties of an object that are keyed by strings.(c) MDN
for (const item in object) {
if (object.hasOwnProperty(item))
log(item);
}
for (const item in object) {
if (!object.hasOwnProperty(item))
continue;
log(item);
}
for (const item of Object.keys(object)) {
log(item);
}
The
forEach()method executes a provided function once for each array element.(c) MDN
Object
.keys(json)
.forEach((name) => {
manage(name, json[name]);
});
[].forEach.call(arguments, (item) => {
console.log(item);
});
for (const name of Object.keys(json)) {
manage(name, json[name]);
}
for (const item of arguments) {
console.log(item);
}
- The
reduce()method executes a user-supplied reducer callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.(c) MDN
You should always look at second argument of a reducer since it changes logic drastically and should read back and forth a couple times to understand what is going on.
Recursive functions like
.reduce()can be powerful but sometimes difficult to understand, especially for less experienced JavaScript developers. If code becomes clearer when using other array methods, developers must weigh the readability tradeoff against the other benefits of using.reduce(). In cases where.reduce()is the best choice, documentation and semantic variable naming can help mitigate readability drawbacks.(c) MDN
Check it out in πPutout Editor.
const result = list.reduce((a, b) => a + b, 1);
let sum = 1;
for (const a of list) {
sum += a;
}
for (const {a, b} of c) {
console.log(a);
}
for (const {a} of c) {
console.log(a);
}
The
Arrayenables storing a collection of multiple items under a single variable name.(c) MDN
for (const a of ['hello']) {
console.log(a);
}
console.log('hello');
for (const a of b) {
const {c} = a;
}
for (const {c} of b) {}
The
Array.from()static method creates a new, shallow-copiedArrayinstance from an iterable or array-like object.(c) MDN
for (const x of Array.from(y)) {}
for (const x of y) {}
The
forstatement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement to be executed in the loop.(c) MDN
const n = items.length;
for (let i = 0; i < n; i++) {
const item = items[i];
log(item);
}
for (const item of items) {
log(item);
}
for (let i = 0; i < array.length; i++) {
const item = array[i];
console.log(item);
}
for (const item of items) {
log(item);
}
for (let i = 0; i < array.length; i++) {
const item = array[i];
console.log(i, item);
}
for (const [i, item] of array.entries()) {
console.log(i, item);
}
const n = array.length;
for (let i = 0; i < n; i++) {
const item = array[i];
console.log(i, item);
}
for (const [i, item] of array.entries()) {
console.log(i, item);
}
The
entries()method ofArrayinstances returns a new array iterator object that contains the key/value pairs for each index in the array.(c) MDN
Index overwrites on each iteration so when it modified inside loop it has no effect so for should be used in this case. Checkout in πPutout Editor.
for (let [i, token] of tokens.entries()) {
++i;
}
const n = tokens.length;
for (let i = 0; i < n; i++) {
++i;
}
MIT
FAQs
πPutout plugin adds ability to apply for...of
The npm package @putout/plugin-for-of receives a total of 6,667 weekly downloads. As such, @putout/plugin-for-of popularity was classified as popular.
We found that @putout/plugin-for-of demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.