@vasturiano/flatten
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

flatten

NPM package Build Size NPM Downloads

A utility function to recursively flatten nested arrays with arbitrary levels

flatten(array)

Quick start

import flatten from '@vasturiano/flatten';

or using a script tag

<script src="//unpkg.com/@vasturiano/flatten"></script>

Usage example

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]

/@vasturiano/flatten/

    Package Sidebar

    Install

    npm i @vasturiano/flatten

    Weekly Downloads

    6

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    8.73 kB

    Total Files

    8

    Last publish

    Collaborators

    • vasturiano