Sha256: 2410fc4a7f9e866d23e642ad2b93e599d792d89c95715b76993e3da98a86ac1f

Contents?: true

Size: 1.17 KB

Versions: 300

Compression:

Stored size: 1.17 KB

Contents

var arrayPush = require('./_arrayPush'),
    isFlattenable = require('./_isFlattenable');

/**
 * The base implementation of `_.flatten` with support for restricting flattening.
 *
 * @private
 * @param {Array} array The array to flatten.
 * @param {number} depth The maximum recursion depth.
 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
 * @param {Array} [result=[]] The initial result value.
 * @returns {Array} Returns the new flattened array.
 */
function baseFlatten(array, depth, predicate, isStrict, result) {
  var index = -1,
      length = array.length;

  predicate || (predicate = isFlattenable);
  result || (result = []);

  while (++index < length) {
    var value = array[index];
    if (depth > 0 && predicate(value)) {
      if (depth > 1) {
        // Recursively flatten arrays (susceptible to call stack limits).
        baseFlatten(value, depth - 1, predicate, isStrict, result);
      } else {
        arrayPush(result, value);
      }
    } else if (!isStrict) {
      result[result.length] = value;
    }
  }
  return result;
}

module.exports = baseFlatten;

Version data entries

300 entries across 276 versions & 32 rubygems

Version Path
disco_app-0.18.2 test/dummy/node_modules/lodash/_baseFlatten.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/lodash/_baseFlatten.js
trusty-cms-5.0.7 node_modules/lodash/_baseFlatten.js
appmap-0.72.2 ./node_modules/lodash/_baseFlatten.js
trusty-cms-5.0.6 node_modules/lodash/_baseFlatten.js
appmap-0.72.1 ./node_modules/lodash/_baseFlatten.js
appmap-0.72.0 ./node_modules/lodash/_baseFlatten.js
trusty-cms-5.0.5 node_modules/lodash/_baseFlatten.js
trusty-cms-5.0.4 node_modules/lodash/_baseFlatten.js
appmap-0.71.0 ./node_modules/lodash/_baseFlatten.js
disco_app-0.16.1 test/dummy/node_modules/lodash/_baseFlatten.js
appmap-0.70.2 ./node_modules/lodash/_baseFlatten.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/lodash/_baseFlatten.js
appmap-0.70.1 ./node_modules/lodash/_baseFlatten.js
appmap-0.70.0 ./node_modules/lodash/_baseFlatten.js
appmap-0.69.0 ./node_modules/lodash/_baseFlatten.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/lodash/_baseFlatten.js
appmap-0.68.2 ./node_modules/lodash/_baseFlatten.js
appmap-0.68.1 ./node_modules/lodash/_baseFlatten.js
disco_app-0.15.2 test/dummy/node_modules/lodash/_baseFlatten.js