# babel-plugin-transform-object-spread-inline

> Object spread transpiler

Latest version **0.0.3** (published 2018-12-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-object-spread-inline
pnpm add babel-plugin-transform-object-spread-inline
yarn add babel-plugin-transform-object-spread-inline
bun add babel-plugin-transform-object-spread-inline
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-12-02 |
| First published | 2016-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | finom |
| Keywords | babel-plugin, syntax, spread |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-object-spread-inline
- Repository: https://github.com/finom/babel-plugin-transform-object-spread-inline
- Homepage: https://github.com/finom/babel-plugin-transform-object-spread-inline#readme
- Issues: https://github.com/finom/babel-plugin-transform-object-spread-inline/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-object-spread-inline

## Dependencies (4)

- [better-log](https://npm.io/package/better-log.md) ^1.3.3
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.1.5
- [@babel/template](https://npm.io/package/@babel/template.md) ^7.1.2
- [@babel/plugin-syntax-object-rest-spread](https://npm.io/package/@babel/plugin-syntax-object-rest-spread.md) ^7.0.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2018-12-02
- 0.0.2 — 2016-08-01
- 0.0.1 — 2016-08-01
- 0.0.0 — 2016-05-11

## README

# babel-plugin-transform-object-spread-inline [![npm version](https://badge.fury.io/js/babel-plugin-transform-object-spread-inline.svg)](https://badge.fury.io/js/babel-plugin-transform-object-spread-inline)

> Transpiles object spread to fast inline code.

Installation:
```sh
npm install --save-dev babel-plugin-transform-object-spread-inline
```

Usage (via .babelrc)
```json
{
	"plugins": [
		"transform-object-spread-inline"
	]
}
```

## What does it do?

Converts this kind of code:
```js
a = { b, c, ...d, e, f: 42 };
```

To this:
```js
"use strict";
var _keys,
    _l,
    _i,
    _source,
    _key,
    _result = {};

_result.b = b
_result.c = c

for (_source = d, _keys = Object.keys(_source), _l = _keys.length, _i = 0; _i < _l; _i++) {
  _key = _keys[_i];
  _result[_key] = _source[_key];
}

_result.e = e
_result.f = 42
a = _result;
```

Instead of:
```js
"use strict";

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

a = _extends({ b: b, c: c }, d, { e: e, f: 42 });
```
(generated by babel-plugin-transform-object-rest-spread)

The first runs only one fast (because of ``Object.keys``) loop with N iterations + inline assignments, the second runs the function which contains a loop (3 iterations), which runs another loop (2 + N + 2 iterations) which is slow because of ``for..in`` and ``hasOwnProperty``.

The idea is very simple: every spread operator is converted to one ``for`` loop, and property listing is converted to simple assignments. When you have X spread operators per object, you get X loops, but usially only one spread operator is used in real world. Be careful and don't use too many spreads (otherwise don't use this plugin).

**Warning**: This plugin doesn't transpile object rest syntax.

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