src/immutable-lodash.js
function sampleSize(iterable, n=1) {
  let index = -1
  let result = List(iterable)
  const length = result.size
  const lastIndex = length - 1

  while (++index < n) {
    const rand = lodash.random(index, lastIndex)
    const value = result.get(rand)

    result = result.set(rand, result.get(index))
    result = result.set(index, value)
  }

  return result.slice(0, Math.min(length, n))
}
function sampleSize(iterable, n=1) {
  let index = -1
  let result = List(iterable)
  const length = result.size
  const lastIndex = length - 1

  while (++index < n) {
    const rand = lodash.random(index, lastIndex)
    const value = result.get(rand)

    result = result.set(rand, result.get(index))
    result = result.set(index, value)
  }

  return result.slice(0, Math.min(length, n))
}
function sampleSize ( iterable , n = 1 ) { let index = - 1 let result = List ( iterable ) const length = result . size const lastIndex = length - 1 while ( ++ index < n ) { const rand = lodash . random ( index , lastIndex ) const value = result . get ( rand ) result = result . set ( rand , result . get ( index ) ) result = result . set ( index , value ) } return result . slice ( 0 , Math . min ( length , n ) ) }
Gets `n` random elements at unique keys from `iterable` up to the
size of `iterable`.

@static
@memberOf _
@category iterable
@param {Iterable} iterable The iterable to sample.
@param {number} [n=1] The number of elements to sample.
@returns {List} Returns the random elements.
@example

_.sampleSize([1, 2, 3], 2)
// => List [3, 1]

_.sampleSize([1, 2, 3], 4)
// => List [2, 3, 1]
Gets n random elements at unique keys from iterable up to the size of iterable .