JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 141937
  • Score
    100M100P100Q154191F
  • License MIT

Flatten a nested array.

Package Exports

  • flat-util

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (flat-util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

flat-util Build Status

Flatten a nested array.

Creates a new array with all sub-array elements concatenated into it recursively.

Features

  • Small utility script to flatten nested arrays.
  • Supports the CommonJS module format.
  • Free of TypeScript. 😄

Install

Install with npm

$ npm install flat-util

Or unpkg

<script src="https://unpkg.com/browse/flat-util@1.0.4/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, [5, 6]]]);
//=> [1, 2, 3, 4, 5, 6]

API

flatten(input)

input

Type: array Default: none

The array to flatten.

License

MIT