@kingjs/array.nested.to-array

Returns an array containing the non-array leafs of a tree whose internal nodes are nested arrays.

Stats

StarsIssuesVersionUpdatedCreatedSize
@kingjs/array.nested.to-array
1.0.53 years ago3 years agoMinified + gzip package size for @kingjs/array.nested.to-array in KB

Readme

@kingjs/array.nested.to-array

Returns an array containing the non-array leafs of a tree whose internal nodes are nested arrays.

Usage

Flatten nested arrays like this:

var toArray = require('@kingjs/array.nested.toArray');

var result = toArray([
  'a', [
    'b', [
      'c'
    ], 'd'
  ], 'e'
]);

result;

result:

[ 'a', 'b', 'c', 'd', 'e' ]

API

declare function toArray(
  target: any | any[]
): any[]

Parameters

  • target: An non-array leaf or an array of nested array nodes interspersed with non-array leafs.

    Returns

    Returns an array containing the non-array leafs of a tree whose internal nodes are nested arrays.

    Install

    With npm installed, run
    $ npm install @kingjs/array.nested.to-array
    

    License

    MIT

Analytics

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.