Sha256: c44da3f38014348590d536db98b665436e7731a5db97e9b01b3d1eeaf86ad82b

Contents?: true

Size: 1.5 KB

Versions: 153

Compression:

Stored size: 1.5 KB

Contents

var baseIndexOf = require('./baseIndexOf'),
    cacheIndexOf = require('./cacheIndexOf'),
    createCache = require('./createCache');

/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;

/**
 * The base implementation of `_.uniq` without support for callback shorthands
 * and `this` binding.
 *
 * @private
 * @param {Array} array The array to inspect.
 * @param {Function} [iteratee] The function invoked per iteration.
 * @returns {Array} Returns the new duplicate free array.
 */
function baseUniq(array, iteratee) {
  var index = -1,
      indexOf = baseIndexOf,
      length = array.length,
      isCommon = true,
      isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
      seen = isLarge ? createCache() : null,
      result = [];

  if (seen) {
    indexOf = cacheIndexOf;
    isCommon = false;
  } else {
    isLarge = false;
    seen = iteratee ? [] : result;
  }
  outer:
  while (++index < length) {
    var value = array[index],
        computed = iteratee ? iteratee(value, index, array) : value;

    if (isCommon && value === value) {
      var seenIndex = seen.length;
      while (seenIndex--) {
        if (seen[seenIndex] === computed) {
          continue outer;
        }
      }
      if (iteratee) {
        seen.push(computed);
      }
      result.push(value);
    }
    else if (indexOf(seen, computed, 0) < 0) {
      if (iteratee || isLarge) {
        seen.push(computed);
      }
      result.push(value);
    }
  }
  return result;
}

module.exports = baseUniq;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
blackboard-3.1.9 lib/site_template/node_modules/opt-merger/node_modules/lodash/internal/baseUniq.js
blackboard-3.1.9 lib/site_template/node_modules/easy-extender/node_modules/lodash/internal/baseUniq.js
babel-schmooze-sprockets-0.1.1 node_modules/lodash/internal/baseUniq.js
babel-schmooze-sprockets-0.1.0 node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/internal/baseUniq.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/lodash/internal/baseUniq.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/lodash/internal/baseUniq.js
trusty-festivity-extension-2.5.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseUniq.js