1.1.9 • Published 2 years ago

flat-util v1.1.9

Weekly downloads
56,754
License
MIT
Repository
github
Last release
2 years ago

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.5/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

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

3 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.0-0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago