$ cnpm install @putout/plugin-apply-destructuring
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
Short:
{
"rules": {
"apply-destructuring": "on"
}
}
Full:
{
"rules": {
"apply-destructuring/object": "on",
"apply-destructuring/array": "on",
"apply-destructuring/falsy": "on"
}
}
const first = array[0];
const [first] = array;
const name = user.name;
hello = world.hello;
const {name} = user;
({hello} = world);
Check out in ????Putout Editor.
const {maxElementsInOneLine} = {
options,
};
const {maxElementsInOneLine} = options;
Check out in ????Putout Editor.
const {0: a, 1: b} = c;
const [a, b] = c;
MIT
Copyright 2013 - present © cnpmjs.org | Home |