2.0.0 • Published 1 year ago

flat-nested-objects v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

flat-nested-objects

This Package will flat the nested objects and returns a simple object that has all nested keys and their values available to use at initial level

Installation

Using NPM

$ npm i flat-nested-objects

Using YARN

$ yarn add flat-nested-objects

Usage

import flatNestedObjects from 'flat-nested-objects';
const { actual_required_key } = flatNestedObjects(complexObj);

output;
console.log(actual_required_key); // Prints required_value

Example

let complexObj = {
	level_one: {
		level_two: {
			level_three: {
				level_four: {
					level_five: {
						level_six: {
							level_seven: {
								level_n: { actual_required_key: 'required_value' }
							}
						}
					}
				}
			}
		}
	}
};

Problem Statement for the Above Example

As you can see in above example the actual required key is in nth level which somtimes becomes complex to travel through object keys and reach the actual key to get the required value.

Solution for the Above Example

In this kind of situation we can use flat-nested-objects library and pass the complex object to it as argument, the function will return required value at the 1st level when destructured.

2.0.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.9.2

1 year ago

1.0.0

2 years ago