# @vasturiano/flatten

> Recursively flatten nested arrays with arbitrary levels

Latest version **1.1.2** (published 2025-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vasturiano/flatten
pnpm add @vasturiano/flatten
yarn add @vasturiano/flatten
bun add @vasturiano/flatten
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2025-04-09 |
| First published | 2018-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vasco Asturiano |
| Maintainers | vasturiano |
| Keywords | flatten, array, nested, recursive |

## Links

- npm: https://www.npmjs.com/package/@vasturiano/flatten
- Repository: https://github.com/vasturiano/flatten
- Issues: https://github.com/vasturiano/flatten/issues
- npm.io page: https://npm.io/package/@vasturiano/flatten

## Recent versions

- 1.1.2 (latest) — 2025-04-09
- 1.1.1 — 2023-02-08
- 1.1.0 — 2023-02-07
- 1.0.6 — 2022-02-09
- 1.0.5 — 2021-05-05
- 1.0.4 — 2020-03-18
- 1.0.3 — 2020-03-15
- 1.0.2 — 2019-06-13
- 1.0.1 — 2019-06-12
- 1.0.0 — 2018-03-10

## 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
<script src="//cdn.jsdelivr.net/npm/@vasturiano/flatten"></script>
```

## 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

---
_Source: https://npm.io/package/@vasturiano/flatten · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
