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

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

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

🐊Putout plugin adds ability to convert for-in to for-of

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.3K
increased by29.9%
Maintainers
1
Weekly downloads
 
Created
Source

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

The for...in statement iterates over all enumerable properties of an object that are keyed by strings.

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 for...in to for...of loop. Merged to @putout/plugin-for-of.

Install

npm i @putout/plugin-convert-for-in-to-for-of -D

Rule

{
    "rules": {
        "convert-for-in-to-for-of/positive": "on",
        "convert-for-in-to-for-of/negative": "on"
    }
}

❌ Example of incorrect code

for (const item in object) {
    if (object.hasOwnProperty(item)) {
        log(item);
    }
}

for (const item in object) {
    if (!object.hasOwnProperty(item))
        continue;
    
    log(item);
}

✅ Example of correct code

for (const item of Object.keys(object)) {
    log(item);
}

License

MIT

Keywords

FAQs

Package last updated on 11 Mar 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