|
6 лет назад | |
---|---|---|
.. | ||
src | 7 лет назад | |
test | 7 лет назад | |
.npmignore | 7 лет назад | |
README.md | 7 лет назад | |
package.json | 6 лет назад |
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"]
});