# @lamansky/flatten

> A one-liner function that flattens arrays.

Latest version **1.0.0** (published 2018-02-03) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-02-03 |
| First published | 2018-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | John Lamansky |
| Maintainers | lamansky |
| Keywords | flatten, nested, array |

## Links

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

## Dependencies (1)

- [sbo](https://npm.io/package/sbo.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2018-02-03

## README

# flatten

A one-liner function that flattens arrays.

## Installation

Requires [Node.js](https://nodejs.org/) 6.0.0 or above.

```bash
npm i @lamansky/flatten
```

## API

The module exports a single function.

### Parameters

1. Bindable: `arr` (Array): The array to be flattened
2. Object argument:
    * Optional: `depth` (integer): Defaults to `Infinity`. If `0`, the original `arr` is returned.

### Return Value

The flattened Array

## Example

```javascript
const flatten = require('@lamansky/flatten')

const arr = [[[1], 2], [3]]

flatten(arr) // [1, 2, 3]
flatten(arr, {depth: 1}) // [[1], 2, 3]
flatten(arr, {depth: 0}) // [[[1], 2], [3]]

// Supports the bind operator
arr::flatten() // [1, 2, 3]
arr::flatten({depth: 1}) // [[1], 2, 3]
```

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