Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

🐊Putout plugin adds ability to convert 'forEach' to 'for...of'

  • 8.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2K
decreased by-8.91%
Maintainers
1
Weekly downloads
 
Created
Source

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

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.

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

Keywords

FAQs

Package last updated on 01 Feb 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc