Sha256: 62043164438968ce5b8c7277d87777cb965bc97add797f314c464bd60ca4cd3a

Contents?: true

Size: 689 Bytes

Versions: 264

Compression:

Stored size: 689 Bytes

Contents

var baseRandom = require('./_baseRandom');

/**
 * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
 *
 * @private
 * @param {Array} array The array to shuffle.
 * @param {number} [size=array.length] The size of `array`.
 * @returns {Array} Returns `array`.
 */
function shuffleSelf(array, size) {
  var index = -1,
      length = array.length,
      lastIndex = length - 1;

  size = size === undefined ? length : size;
  while (++index < size) {
    var rand = baseRandom(index, lastIndex),
        value = array[rand];

    array[rand] = array[index];
    array[index] = value;
  }
  array.length = size;
  return array;
}

module.exports = shuffleSelf;

Version data entries

264 entries across 262 versions & 29 rubygems

Version Path
trusty-cms-6.3.1 node_modules/lodash/_shuffleSelf.js
immosquare-cleaner-0.1.51 node_modules/lodash/_shuffleSelf.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/_shuffleSelf.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
immosquare-cleaner-0.1.50 node_modules/lodash/_shuffleSelf.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
immosquare-cleaner-0.1.49 node_modules/lodash/_shuffleSelf.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js
immosquare-cleaner-0.1.48 node_modules/lodash/_shuffleSelf.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/_shuffleSelf.js