1.1.0 • Published 4 years ago

@feizheng/next-flatten v1.1.0

Weekly downloads
5
License
MIT
Repository
-
Last release
4 years ago

next-flatten

Flattens array a single or multiple level deep.

installation

npm install -S @feizheng/next-flatten

usage

import '@feizheng/next-flatten';

const res = nx.flatten([[1, 2, 3], [4, 5]]); 
// [1, 2, 3, 4, 5]

other solution

function flattenArrayOfArrays(a, r) {
  if (!r) { r = [] }
  for (var i = 0; i < a.length; i++) {
    if (a[i].constructor == Array) {
      r.concat(flattenArrayOfArrays(a[i], r));
    } else {
      r.push(a[i]);
    }
  }
  return r;
}

resources

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago