Skip to content

🍓 non-recursive method of flattening an array or arrays and unflattening the result

License

Notifications You must be signed in to change notification settings

Quernest/arr-flatten-unflatten

Repository files navigation

arr-flatten-unflatten

package version package downloads standard-readme compliant package license

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.


Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •