Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatten

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatten

Flatten arbitrarily nested arrays into a non-nested list of non-array items. Maintained for legacy compatibility.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
increased by2.16%
Maintainers
3
Weekly downloads
 
Created

What is flatten?

The flatten npm package is designed to flatten nested arrays or objects into a single level, making it easier to work with complex data structures. It provides a straightforward and efficient way to reduce the depth of data structures for easier processing and manipulation.

What are flatten's main functionalities?

Flattening arrays

This feature allows you to flatten nested arrays into a single-level array. For example, if you have an array like [[1, 2], [3, 4]], using flatten will result in [1, 2, 3, 4].

[].concat.apply([], array)

Flattening objects

This feature is for flattening nested objects into a single-level array or object, depending on the implementation. It's useful for when you need to simplify the structure of deeply nested objects.

Object.keys(obj).reduce(function(acc, key) { return acc.concat([{key: obj[key]}]); }, [])

Other packages similar to flatten

Keywords

FAQs

Package last updated on 31 Oct 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc