@putout/plugin-convert-for-in-to-for-of
🐊Putout plugin adds ability to convert for-in to for-of
Last updated 3 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-convert-for-in-to-for-of 
SYNC missed versions from official npm registry.

@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

Current Tags

  • 2.0.1                                ...           latest (3 years ago)

8 Versions

  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.4                                ...           6 years ago
  • 1.1.3                                ...           6 years ago
  • 1.1.2                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |