Skip to content

The flatDeep() method creates a new array with all sub-iterables elements concatenated into it recursively up.

License

Notifications You must be signed in to change notification settings

heppokofrontend/flat-deep

Repository files navigation

@heppokofrontend/flat-deep

MIT License Published on NPM test workflow Maintainability Test Coverage Known Vulnerabilities @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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

About

The flatDeep() method creates a new array with all sub-iterables elements concatenated into it recursively up.

Resources

License

Stars

Watchers

Forks