Socket
Socket
Sign inDemoInstall

babel-plugin-transform-optimize-object-literal

Package Overview
Dependencies
54
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-transform-optimize-object-literal

Rewrites object and array literals with JSON.parse calls.


Version published
Weekly downloads
3
Maintainers
1
Install size
14.4 MB
Created
Weekly downloads
 

Readme

Source

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
      }
    ]
  ]
}

Keywords

FAQs

Last updated on 05 Feb 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc