@putout/plugin-convert-object-keys-to-object-entries

1.0.0 • Public • Published

@putout/plugin-convert-object-keys-to-object-entries NPM version

The Object.keys() static method returns an array of a given object's own enumerable string-keyed property key-value pairs.

(c) Object.keys()

The Object.entries() static method returns an array of a given object's own enumerable string-keyed property key-value pairs.

(c) Object.entries()

🐊Putout plugin adds ability to convert Object.entries() to Object.keys()

Install

npm i @putout/plugin-convert-object-keys-to-object-entries -D

Checkout in 🐊Putout Editor.

Rule

{
    "rules": {
        "convert-object-keys-to-object-entries": "on"
    }
}

❌ Example of incorrect code

for (const [key, value] of Object.keys(tokens)) {
    console.log(key, value);
}

for (const [key, value] of keys(tokens)) {
    console.log(key, value);
}

✅ Example of correct code

for (const [key, value] of Object.entries(tokens)) {
    console.log(key, value);
}

for (const [key, value] of Object.entries(tokens)) {
    console.log(key, value);
}

License

MIT

Package Sidebar

Install

npm i @putout/plugin-convert-object-keys-to-object-entries

Weekly Downloads

741

Version

1.0.0

License

MIT

Unpacked Size

4.56 kB

Total Files

4

Last publish

Collaborators

  • coderaiser