@heppokofrontend/flat-deep
v0.2.4
Published
Completely flattens the iterable object.
Downloads
1
Maintainers
Readme
@heppokofrontend/flat-deep
The flatDeep()
method creates a new array with all sub-iterables elements concatenated into it recursively up.
Usage
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]
Syntax
flatDeep(iterable, options);
Parameters
iterable
The iterable object to be flattened.
For Example:
- Array
- Set
- Map
- NodeList
- HTMLCollection
options
|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).|
Contributing
- 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
License
MIT