# @jswork/next-flatten

> Flattens `array` a single or multiple level deep.

Latest version **1.0.2** (published 2023-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jswork/next-flatten
pnpm add @jswork/next-flatten
yarn add @jswork/next-flatten
bun add @jswork/next-flatten
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-04-13 |
| First published | 2020-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | afei |
| Maintainers | afeiship |
| Keywords | next, flatten, flat, array |

## Links

- npm: https://www.npmjs.com/package/@jswork/next-flatten
- Homepage: https://js.work
- npm.io page: https://npm.io/package/@jswork/next-flatten

## Recent versions

- 1.0.2 (latest) — 2023-04-13
- 1.0.1 — 2022-11-17
- 1.0.0 — 2020-11-20

## README

# next-flatten
> Flattens `array` a single or multiple level deep.

[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]

## installation
```bash
npm install -S @jswork/next-flatten
```

## usage
```js
import '@jswork/next-flatten';

const res = nx.flatten([[1, 2, 3], [4, 5]]); 
// [1, 2, 3, 4, 5]
```

## other solution
```js
function flattenArrayOfArrays(a, r) {
  if (!r) { r = [] }
  for (var i = 0; i < a.length; i++) {
    if (a[i].constructor == Array) {
      r.concat(flattenArrayOfArrays(a[i], r));
    } else {
      r.push(a[i]);
    }
  }
  return r;
}
```

## license
Code released under [the MIT license](https://github.com/afeiship/next-flatten/blob/master/LICENSE.txt).

[version-image]: https://img.shields.io/npm/v/@jswork/next-flatten
[version-url]: https://npmjs.org/package/@jswork/next-flatten

[license-image]: https://img.shields.io/npm/l/@jswork/next-flatten
[license-url]: https://github.com/afeiship/next-flatten/blob/master/LICENSE.txt

[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-flatten
[size-url]: https://github.com/afeiship/next-flatten/blob/master/dist/next-flatten.min.js

[download-image]: https://img.shields.io/npm/dm/@jswork/next-flatten
[download-url]: https://www.npmjs.com/package/@jswork/next-flatten

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