Nonchalantly Performs Magic
Learn how companies like Phone2Action are using npm in their front-end developmentJoin the conversation »

arr-flatten-unflatten

1.0.2 • Public • Published

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.


Install

npm i arr-flatten-unflatten

DownloadsWeekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

7.73 kB

Total Files

9

Last publish

Collaborators

  • avatar