Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quernest/arr-flatten-unflatten
🍓 non-recursive method of flattening an array or arrays and unflattening the result
https://github.com/quernest/arr-flatten-unflatten
array array-flattening arrays deflat flat flatdeep flatten flatten-array flattendeep non-recursive unflat unflatten
Last synced: 20 days ago
JSON representation
🍓 non-recursive method of flattening an array or arrays and unflattening the result
- Host: GitHub
- URL: https://github.com/quernest/arr-flatten-unflatten
- Owner: Quernest
- License: mit
- Created: 2019-01-27T11:38:38.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T02:16:25.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T17:08:49.895Z (3 months ago)
- Topics: array, array-flattening, arrays, deflat, flat, flatdeep, flatten, flatten-array, flattendeep, non-recursive, unflat, unflatten
- Language: JavaScript
- Homepage:
- Size: 718 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# arr-flatten-unflatten
[![package version](https://img.shields.io/npm/v/arr-flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/arr-flatten-unflatten)
[![package downloads](https://img.shields.io/npm/dm/arr-flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/arr-flatten-unflatten)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/arr-flatten-unflatten.svg?style=flat-square)](https://npmjs.org/package/arr-flatten-unflatten)> non-recursive method of flattening an array or arrays and unflattening the result
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save arr-flatten-unflatten
```Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add arr-flatten-unflatten
```## Usage
```js
const { flatten, unflatten } = require("arr-flatten-unflatten");let flat = flatten([2, 4, [8, [2, [32, 64]], 7], 5]);
/**
* => {
* "[0]": 2,
* "[1]": 4,
* "[2][0]": 8,
* "[2][1][0]": 2,
* "[2][1][1][0]": 32,
* "[2][1][1][1]": 64,
* "[2][2]": 7,
* "[3]": 5
* }
* */unflatten(flat);
// => [2, 4, [8, [2, [32, 64]], 7], 5]
```### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Author
- [github/Quernest](https://github.com/quernest)
### License
Copyright © 2019, [Quernest](https://github.com/Quernest).
Released under the [MIT License](LICENSE).---