Socket
Book a DemoInstallSign in
Socket

flatten-unflatten

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
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

flatten-unflatten

Flatten or unflatten a object

unpublished
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
6
20%
Maintainers
1
Weekly downloads
 
Created
Source

flatten-unflatten

package version package downloads standard-readme compliant package license make a pull request

Flatten or unflatten a object

Table of Contents

Install

This project uses node and npm.

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

Usage

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

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

License

MIT

Keywords

flatten

FAQs

Package last updated on 24 Nov 2025

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