https://github.com/vasturiano/flatten
Recursively flatten nested arrays with arbitrary levels
https://github.com/vasturiano/flatten
Last synced: 2 months ago
JSON representation
Recursively flatten nested arrays with arbitrary levels
- Host: GitHub
- URL: https://github.com/vasturiano/flatten
- Owner: vasturiano
- License: mit
- Created: 2018-03-10T21:35:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-09T19:58:32.000Z (6 months ago)
- Last Synced: 2025-07-28T11:53:15.440Z (2 months ago)
- Language: JavaScript
- Size: 104 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
flatten
=======[![NPM package][npm-img]][npm-url]
[![Build Size][build-size-img]][build-size-url]
[![NPM Downloads][npm-downloads-img]][npm-downloads-url]A utility function to recursively flatten nested arrays with arbitrary levels
`flatten(array)`
## Quick start
```js
import flatten from '@vasturiano/flatten';
```
or using a *script* tag
```html```
## Usage example
```js
const nestedArray = [
1,
[
2,
[3, 4],
[
5,
6,
[7, 8]
],
9
],
[
10,
[11]
]
];flatten(nestedArray);
// Result:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
```[npm-img]: https://img.shields.io/npm/v/@vasturiano/flatten
[npm-url]: https://npmjs.org/package/@vasturiano/flatten
[build-size-img]: https://img.shields.io/bundlephobia/minzip/@vasturiano/flatten
[build-size-url]: https://bundlephobia.com/result?p=@vasturiano/flatten
[npm-downloads-img]: https://img.shields.io/npm/dt/flatten
[npm-downloads-url]: https://www.npmtrends.com/flatten