✨ Flatify-obj is a simple module that flattens nested javascript objects into a single-depth object.
rocktimsaikia / flatify-obj
Flatten nested javascript objects into a single-depth object.
This module can come in pretty handy in situations where you are dealing with deeply nested objects.
Installation
npm install flatify-obj
Usage
const flattenObject = require('flatify-obj');
flattenObject({foo: {bar: {unicorn: '🦄'}}})
//=> { 'foo.bar.unicorn': '🦄' }
flattenObject({foo: {unicorn: '🦄'}, bar: 'unicorn'}, {onlyLeaves: true});
//=> {unicorn: '🦄', bar: 'unicorn'}
[ PS: I created this tool to use it in a project that I am working on. I thought someone might find it handy so made a quick post. Leave a star at the repo 🌟 if find this helpful. Thanks for reading 🦄 👋]
Top comments (0)