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
immosquare-cleaner-0.1.60 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.59 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.58 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.57 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.56 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.55 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.54 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.53 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.52 node_modules/lodash/_baseFlatten.js
trusty-cms-6.3.1 node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.51 node_modules/lodash/_baseFlatten.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/_baseFlatten.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
immosquare-cleaner-0.1.50 node_modules/lodash/_baseFlatten.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/_baseFlatten.js