Miss any of our Open RFC calls?Watch the recordings here! »

babel-plugin-transform-optimize-object-literal

1.0.2 • Public • Published

babel-plugin-transform-optimize-object-literal

Node.js CI npm version

Because I heard JSON.parse is blazing fast https://v8.dev/blog/cost-of-javascript-2019#json

Input:

const foo = { a: "3", d: "f" };
const bar = [1, 4, -2, true, false, {}, "ok"];

Output:

const foo = JSON.parse('{"a":"3","d":"f"}');
const bar = JSON.parse('[1,4,-2,true,false,{},"ok"]');

Usage

yarn add -D babel-plugin-transform-optimize-object-literal

.babelrc:

{
  "plugins": [
    [
      "babel-plugin-transform-optimize-object-literal",
      {
        "skipArrayOptimizationIfLengthIsBelow": 0,
        "skipObjectOptimizationIfLengthIsBelow": 0
      }
    ]
  ]
}

Install

npm i babel-plugin-transform-optimize-object-literal

DownloadsWeekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

11.7 MB

Total Files

31

Last publish

Collaborators

  • avatar