Neck Protection Mandate

    reduce-deep

    1.3.2 • Public • Published

    reduce-deep

    Deep reduce an array.

    var reduceDeep = require('reduce-deep');
    var assert = require('assert');
    
    function flattenDeep(array) {
      return reduceDeep(
        array,
        function (memo, value) {
          memo.push(value);
          return memo;
        },
        []
      );
    }
    
    var array1 = [1, [2, [3, [4]], 5]];
    assert.deepStrictEqual(flattenDeep(array1), [1, 2, 3, 4, 5]);
    
    var array2 = [[], [[]], [[], [[[]]]]];
    assert.deepStrictEqual(flattenDeep(array2), []);
    

    Install

    npm i reduce-deep

    DownloadsWeekly Downloads

    1,222

    Version

    1.3.2

    License

    MIT

    Unpacked Size

    3.27 kB

    Total Files

    4

    Last publish

    Collaborators

    • kmalakoff