# babel-plugin-transform-optimize-object-literal

> Rewrites object and array literals with JSON.parse calls.

Latest version **1.0.2** (published 2020-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-optimize-object-literal
pnpm add babel-plugin-transform-optimize-object-literal
yarn add babel-plugin-transform-optimize-object-literal
bun add babel-plugin-transform-optimize-object-literal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-02-05 |
| First published | 2020-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | keyanzhang |
| Keywords | babel, optimize, react, json, JSON.parse, performance, speed |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-optimize-object-literal
- Repository: https://github.com/keyz/babel-plugin-transform-optimize-object-literal
- Homepage: https://github.com/keyz/babel-plugin-transform-optimize-object-literal#readme
- Issues: https://github.com/keyz/babel-plugin-transform-optimize-object-literal/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-optimize-object-literal

## Dependencies (2)

- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.8.4
- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.8.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-02-05
- 1.0.1 — 2020-02-02
- 1.0.0 — 2020-02-02

## README

# babel-plugin-transform-optimize-object-literal

[![Node.js CI](https://github.com/keyz/babel-plugin-transform-optimize-object-literal/workflows/Node.js%20CI/badge.svg)](https://github.com/keyz/babel-plugin-transform-optimize-object-literal/actions "CI Status") [![npm version](http://img.shields.io/npm/v/babel-plugin-transform-optimize-object-literal.svg?style=flat)](https://npmjs.org/package/babel-plugin-transform-optimize-object-literal "View on npm")

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

Input:

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

Output:

```javascript
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`:

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

---
_Source: https://npm.io/package/babel-plugin-transform-optimize-object-literal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
