arr-flatten-unflatten

    1.1.4 • 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

    2

    Version

    1.1.4

    License

    MIT

    Unpacked Size

    5.89 kB

    Total Files

    10

    Last publish

    Collaborators

    • avatar