# flatten-unflatten

> Flatten or unflatten a object

Latest version **1.0.0** (published 2018-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install flatten-unflatten
pnpm add flatten-unflatten
yarn add flatten-unflatten
bun add flatten-unflatten
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-14 |
| First published | 2018-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tiaan du Plessis |
| Maintainers | tiaanduplessis |
| Keywords | flatten, unflatten |

## Links

- npm: https://www.npmjs.com/package/flatten-unflatten
- Repository: https://github.com/tiaanduplessis
- npm.io page: https://npm.io/package/flatten-unflatten

## Dependencies (1)

- [set-nested-prop](https://npm.io/package/set-nested-prop.md) ^2.0.0

## Recent versions

- 1.0.0 (latest) — 2018-06-14

## README

# flatten-unflatten
[![package version](https://img.shields.io/npm/v/flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/flatten-unflatten)
[![package downloads](https://img.shields.io/npm/dm/flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/flatten-unflatten)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/flatten-unflatten)
[![make a pull request](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

> Flatten or unflatten a object

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)

## Install

This project uses [node](https://nodejs.org) and [npm](https://www.npmjs.com). 

```sh
$ npm install flatten-unflatten
$ # OR
$ yarn add flatten-unflatten
```

## Usage

```js
import {flatten, unflatten} from 'flatten-unflatten'

const foo = {
  bar: 5,
  baz: {
    bar: 1,
    foo: {
      ping: 'pong',
      arr: [1, 3, 4, 5]
    }
  }
}

const flatFoo = flatten(foo)
console.log(flatFoo) // {bar: 5, baz.bar: 1, baz.foo.ping: "pong", baz.foo.arr: Array[4]}

const starryFlatFoo = flatten(foo, { delimiter: '*' })
console.log(starryFlatFoo) // {bar: 5, baz*bar: 1, baz*foo*ping: "pong", baz*foo*arr: Array[4]}
console.log(flatten(foo, { arrays: true })) // {bar: 5, baz.bar: 1, baz.foo.ping: "pong", baz.foo.arr.0: 1, baz.foo.arr.1: 3…}

console.log(unflatten(flatFoo)) // {bar: 5, baz: Object}
console.log(unflatten(starryFlatFoo, { delimiter: '*' })) // {bar: 5, baz: Object}

```

## Contribute

1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature 
4. Submit a pull request

## License

MIT

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