This package has been deprecated

Author message:

see @kingjs/descriptor.nested.array.for-each

@kingjs/array.nested.for-each

1.0.6 • Public • Published

@kingjs/array.nested.for-each

Invokes a callback on leafs of a tree whose internal nodes are nested arrays and whose leafs are any non-array value.

Usage

Flatten nested arrays like this:

var forEach = require('@kingjs/array.nested.for-each');

var result = [];

forEach([
  'a', [
    'b', [
      'c'
    ], 'd'
  ], 'e'
], function(x) {
  result.push(x);
});

result;

result:

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

API

declare function forEach(
  target: any | any[],
  callback: (x) => void
)

Parameters

  • target: An non-array leaf or an array of nested array nodes interspersed with non-array leafs.
  • callback: Callback to invoke for each non-array element.
    • x: Current non-array leaf.

Install

With npm installed, run

$ npm install @kingjs/array.nested.for-each

License

MITAnalytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/array.nested.for-each

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

2.99 kB

Total Files

4

Last publish

Collaborators

  • kingces95