🐊Putout plugin adds ability to convert 'const' to 'let'
npm install @putout/plugin-convert-object-entries-to-array-entries[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-object-entries-to-array-entries.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-object-entries-to-array-entries "npm"
> The Object.entries() static method returns an array of a given object's own enumerable string-keyed property key-value pairs.
>
> (c) Object.entries()
> The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array.
>
> (c) Array.prototype.entries()
🐊Putout plugin adds ability to convert Object.entries() to Array.prototype.entries() to avoid bugs
related to using index in unary (!index) or binary (index > length) expressions, the thing is Object.entries() returns list of Array tuples,
and Array.prototype.entries() returns list of Array tuples it can lead to bugs when you expected that index is number.
Check out in 🐊Putout Editor.
```
npm i @putout/plugin-convert-object-entries-to-array-entries -D
`json`
{
"rules": {
"convert-object-entries-to-array-entries": "on"
}
}
`js
const {entries} = Object;
for (const [i, token] of entries(tokens)) {
if (!i)
continue;
fn(token);
}
`
`js``
for (const [i, token] of tokens.entries()) {
if (!i)
continue;
fn(token);
}
MIT