The flatDeep()
method creates a new array with all sub-iterables elements concatenated into it recursively up.
Installation:
npm install --save @heppokofrontend/flat-deep
Example:
import { flatDeep } from '@heppokofrontend/flat-deep';
const map = new Map();
const set = new Set();
const arr = [
0,
'hoge',
[
1,
2,
[
set,
map,
],
],
6,
];
set.add(3);
map.set(4, [5]);
console.log(flatDeep(arr)); // > [0, 'hoge', 1, 2, 3, 4, 5, 6]
flatDeep(iterable, options);
The iterable object to be flattened.
For Example:
- Array
- Set
- Map
- NodeList
- HTMLCollection
property | type | default | required | description |
---|---|---|---|---|
stringIgnore |
boolean |
true |
none | Whether to ignore the string type. |
circularReferenceToJson |
boolean |
false |
none | If a circular reference is found, convert it to JSON without ignoring it. The circular reference will be replaced by the string [Circular] (see fast-safe-stringify). |
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT