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

flat-util

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-util

Flatten a nested array.

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
194K
increased by1.94%
Maintainers
1
Weekly downloads
 
Created
Source

flat-util Build Status

Flatten a nested array.

The nesting can be to any depth. If you pass shallow, the array will only be flattened one level.

Features

  • Small utility to flatten nested arrays.
  • Free of TypeScript. 😄

Install

Install with npm

$ npm install flat-util

Or unpkg

<script src="https://unpkg.com/flat-util@1.1.0/umd/index.js" />

Check out the unit tests on CodePen.

Usage

const flatten = require('flat-util');

flatten([1, 2, [3, 4]]);
//=> [1, 2, 3, 4]

flatten([1, [2], [3, [[4]]]]);
//=> [1, 2, 3, 4];

flatten([1, [2], [3, [[4]]]], true);
//=> [1, 2, 3, [[4]]];

Like us a lot? Help others know why you like us! Review this package on pkgreview.devReview us on pkgreview.dev

API

flatten(input, shallow)

input

Type: array
Default: none

The array to flatten.

shallow

Type: boolean
Default: false

Whether or not to flatten the array only one level.

License

MIT

Keywords

FAQs

Package last updated on 20 Feb 2020

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