🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

babel-plugin-transform-optimize-object-literal

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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.

1.0.2
latest
Source
npm
Version published
Maintainers
1
Created
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

babel

FAQs

Package last updated on 05 Feb 2020

Did you know?

Socket

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