# rolling-pin

> Flatten nested objects into something smoother.

Latest version **0.1.0** (published 2020-02-28) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install rolling-pin
pnpm add rolling-pin
yarn add rolling-pin
bun add rolling-pin
```

## 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.1.0 |
| Published | 2020-02-28 |
| First published | 2020-02-28 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 280 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matthew Carter |
| Maintainers | ahungry |

## Links

- npm: https://www.npmjs.com/package/rolling-pin
- Repository: https://github.com/ahungry/rolling-pin
- Homepage: https://github.com/ahungry/rolling-pin#readme
- Issues: https://github.com/ahungry/rolling-pin/issues
- npm.io page: https://npm.io/package/rolling-pin

## Recent versions

- 0.1.0 (latest) — 2020-02-28
- 0.0.1 — 2020-02-28

## README

# Rolling Pin

Flatten out nasty nested JSON into something simpler and smoother.

Try it out at: http://rolling-pin.ahungry.com/

Interactively (GUI or code lib) turn this:

```json
{
  "person": {
    "identifyingInformation": {
      "hint": "Click 'name' and enter name in the prompt, then 'uuid' and enter 'id'.",
      "fullName": "Matthew Carter",
      "uuid": "abc-123"
    },
    "physicalCharacteristics": {
      "head": {
        "eyes": {
          "left": {
            "hint": "Click 'color' and enter 'leftEye' in the prompt.",
            "color": "blue"
          },
          "right": {
            "hint": "Click 'color' and enter 'rightEye' in the prompt.",
            "color": "blue"
          }
        }
      }
    }
  }
}
```

into this:

```json
{
  "name": "Matthew Carter",
  "id": "abc-123",
  "leftEye": "blue",
  "rightEye": "blue"
}
```

With two-way data-mapping.

# Libs

Add to your project with:

```shell
npm install rolling-pin || yarn add rolling-pin
```

## Simple example


```javascript
const { transform } = require('rolling-pin')

console.log(transform([['a.b', 'x.y']])({a: { b: 3 }}))

// { x: { y: 3 } }
```

## More complex example

```javascript
const { transform } = require('rolling-pin')

const mapping = [
  ['headers.Host'  , 'host'],
  ['origin'        , 'origin'],
  ['json.sentinel' , 'sentinel'],
]
const t = transform(mapping)

const x = t({
  headers: { Host: 'some-host' },
  origin: 'some-origin',
  json: { sentinel: 'some-sentinel' },
})

// Which will produce x as follows:
{
  host: 'some-host',
  origin: 'some-origin',
  sentinel: 'some-sentinel'
}

```

# License

Copyright © 2020 Matthew Carter <m@ahungry.com>

Distributed under the GNU General Public License version 3.0 (GPLv3).

See [LICENSE](https://github.com/ahungry/rolling-pin/blob/master/LICENSE) for details and exceptions.

---
_Source: https://npm.io/package/rolling-pin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
