πPutout plugin adds ability use destructuring on variable declarations
npm install @putout/plugin-apply-destructuring[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-apply-destructuring.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-apply-destructuring"npm"
> The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
>
> (c) MDN
πPutout plugin adds ability to use destructuring on variable declarations. Renamed to @putout/plugin-destructuring.
```
npm i @putout/plugin-apply-destructuring
- β
object;
- β
array;
- β
falsy;
- β
convert-object-to-array;
Short:
`json`
{
"rules": {
"apply-destructuring": "on"
}
}
Full:
`json`
{
"rules": {
"apply-destructuring/object": "on",
"apply-destructuring/array": "on",
"apply-destructuring/falsy": "on"
}
}
`js`
const first = array[0];
`js`
const [first] = array;
`js
const name = user.name;
hello = world.hello;
`
`js
const {name} = user;
({hello} = world);
`
Check out in πPutout Editor.
`js`
const {maxElementsInOneLine} = {
options,
};
`js`
const {maxElementsInOneLine} = options;
Check out in πPutout Editor.
`js`
const {0: a, 1: b} = c;
`js``
const [a, b] = c;
MIT