Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

flatify-obj

RocktimSaikia1.5kMIT2.0.0TypeScript support: included

Flatten nested javascript objects into a single-depth object.

Flatten, flat, object, objects, flatten-object, flat-object

readme

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