babel-plugin-transform-object-destructuring-to-dot-notation
v1.0.0
Published
Replaces identifiers from a destructured object by object dot notation
Downloads
3
Maintainers
Readme
babel-plugin-transform-object-destructuring-to-dot-notation
Replaces identifiers from a destructured object by its object dot notation.
Input:
const { a, b, c } = myObject;
console.log(a, b, c);
Output:
console.log(myObject.a, myObject.b, myObject.c);
Install
npm i babel-plugin-transform-object-destructuring-to-dot-notation
Usage
With a configuration file (.babelrc
)
{
"plugins": [
["babel-plugin-transform-object-destructuring-to-dot-notation", {
"objects": ["myObject"]
}]
]
}
Via Node API
require('@babel/core').transform('code', {
plugins: ['babel-plugin-transform-object-destructuring-to-dot-notation', {
objects: ['myObject']
}],
});
Options
objects
Array
, defaults to undefined
.
e.g. ['babel-plugin-transform-object-destructuring-to-dot-notation', {
objects: ['objectOne', 'objectTwo']
}]
List of object names which destructured properties should be transformed to dot notation.
License
This project is licensed under the MIT License.