npm.io
1.0.0 • Published 10 months ago

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

Licence
MIT
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
797

@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

Keywords