|
6 år sedan | |
---|---|---|
.. | ||
src | 6 år sedan | |
test | 6 år sedan | |
.npmignore | 6 år sedan | |
README.md | 6 år sedan | |
package.json | 6 år sedan |
Transforms old code that uses Object.assign
with an Object Literal as
the first param to use Object Spread syntax.
const obj = Object.assign({
test1: 1,
}, other, {
test2: 2,
}, other2);
Is transformed to:
const obj = {
test1: 1,
...other,
test2: 2,
...other2,
};
npm install --save-dev @babel/plugin-codemod-object-assign-to-object-spread
.babelrc
(Recommended).babelrc
{
"plugins": ["@babel/plugin-codemod-object-assign-to-object-spread"]
}
babel --plugins @babel/plugin-codemod-object-assign-to-object-spread script.js
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-codemod-object-assign-to-object-spread"]
});