🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

flat

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat

Take a nested Javascript object and flatten it, or unflatten an object with delimited keys

1.0.0
Source
npm
Version published
Weekly downloads
24M
-10.08%
Maintainers
1
Weekly downloads
 
Created

What is flat?

The flat npm package allows for flattening and unflattening complex nested objects and arrays in JavaScript. It can be used to convert deeply nested objects into a single level object with dot-separated keys, or to expand a flat object with dot-separated keys back into a nested structure. This can be particularly useful when dealing with data that needs to be stored in a format that doesn't support nested structures, such as certain databases, or when you need to simplify the structure of data for processing or transmission.

What are flat's main functionalities?

Flatten

Converts a nested object into a flat object with dot-separated keys. In the code sample, the 'flatten' method is used to transform the 'original' object into a single-level 'flattened' object with keys like 'b.c' and 'b.d.e'.

{"original": {"a": 1, "b": {"c": 2, "d": {"e": 3}}}, "flattened": flat.flatten({"a": 1, "b": {"c": 2, "d": {"e": 3}}})}

Unflatten

Converts a flat object with dot-separated keys back into a nested object. In the code sample, the 'unflatten' method is used to transform the 'flattened' object back into its original nested structure.

{"flattened": {"a": 1, "b.c": 2, "b.d.e": 3}, "unflattened": flat.unflatten({"a": 1, "b.c": 2, "b.d.e": 3})}

Other packages similar to flat

Keywords

flat

FAQs

Package last updated on 30 Apr 2013

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