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: 9 months 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T02:16:25.000Z (over 3 years ago)
- Last Synced: 2025-01-30T16:57:32.893Z (over 1 year 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
[](https://npmjs.org/package/arr-flatten-unflatten)
[](https://npmjs.org/package/arr-flatten-unflatten)
[](https://github.com/RichardLitt/standard-readme)
[](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).
---