arr-flatten-unflatten
v1.1.4
Published
non-recursive method of flattening an array or arrays and unflattening the result
Downloads
43
Maintainers
Readme
arr-flatten-unflatten
non-recursive method of flattening an array or arrays and unflattening the result
Install
Install with npm:
$ npm install --save arr-flatten-unflatten
Install with yarn:
$ yarn add arr-flatten-unflatten
Usage
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.
Author
License
Copyright © 2019, Quernest. Released under the MIT License.