Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 18, 2024 via pnpm

flat 5.0.2

Take a nested Javascript object and flatten it, or unflatten an object with delimited keys
Package summary
Share
0
issues
1
license
1
BSD-3-Clause
Package created
5 Oct 2012
Version published
6 Aug 2020
Maintainers
3
Total deps
1
Direct deps
0
License
BSD-3-Clause

Issues

0
This package has no issues

Licenses

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
flat@5.0.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of flat 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does flat do?

Flat is a powerful JavaScript library that provides a simple way to flatten and unflatten deeply nested objects. This capability can simplify complex nested structures into a single-level object representation, or vice versa. This functionality proves especially useful when handling complex JSON objects or building data transformation pipelines in JavaScript.

How do you use flat?

You can use the flat library in a JavaScript project by first installing it with npm using npm install flat. After installation, you can import the flatten and unflatten functions from it.

Below are example usages:

Flattening an object:

import { flatten } from 'flat'

const result = flatten({
    key1: {
        keyA: 'valueI'
    },
    key2: {
        keyB: 'valueII'
    },
    key3: { a: { b: { c: 2 } } }
})

console.log(result);
// Outputs: { 'key1.keyA': 'valueI', 'key2.keyB': 'valueII', 'key3.a.b.c': 2 }

Unflattening an object:

import { unflatten } from 'flat'

const result = unflatten({
    'three.levels.deep': 42,
    'three.levels': {
        nested: true
    }
})

console.log(result);
// Outputs: { three: { levels: { deep: 42, nested: true } } }

Where are the flat docs?

The official documentation for flat can be found in the README file of its GitHub repository. Here you can find comprehensive details on installation, usage, options for customization, and examples. You can also learn about its command-line usage for directly dealing with JSON files.