@babel/plugin-codemod-object-assign-to-object-spread

Transforms Object.assign into object spread syntax

Stats

StarsIssuesVersionUpdatedCreatedSize
@babel/plugin-codemod-object-assign-to-object-spread
39,5007337.10.4a year ago3 years agoMinified + gzip package size for @babel/plugin-codemod-object-assign-to-object-spread in KB

Readme

@babel/plugin-codemod-object-assign-to-object-spread

Transforms old code that uses Object.assign with an Object Literal as the first param to use Object Spread syntax.

Examples

const obj = Object.assign({
  test1: 1,
}, other, {
  test2: 2,
}, other2);

Is transformed to:

const obj = {
  test1: 1,
  ...other,
  test2: 2,
  ...other2,
};

Installation

npm install --save-dev @babel/plugin-codemod-object-assign-to-object-spread

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@babel/plugin-codemod-object-assign-to-object-spread"]
}

Via CLI

babel --plugins @babel/plugin-codemod-object-assign-to-object-spread script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-codemod-object-assign-to-object-spread"]
});

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.