flatify-obj
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

flatify-obj build license

Flatten nested javascript objects into a single-depth object.

Install

npm install flatify-obj

Usage

   const flatifyObject = require('flatify-obj');
 
   flatifyObject({foo: {bar: {unicorn: '🦄'}}})
   //=> { 'foo.bar.unicorn': '🦄' }
 
   flatifyObject({foo: {unicorn: '🦄'}, bar: 'unicorn'}, {onlyLeaves: true});
   //=> {unicorn: '🦄', bar: 'unicorn'}

API

flatifyObject(object, options?)

object

Type: object
Object to flatten

options

onlyLeaves

Type: boolean
Default: false

Removes the parent property and only returns the leaf nodes of the object

Support

Package Sidebar

Install

npm i flatify-obj

Weekly Downloads

196

Version

2.0.0

License

MIT

Unpacked Size

4.49 kB

Total Files

5

Last publish

Collaborators

  • rocktimsaikia