function shuffleUnique( arr ) {
  // Try to prevent infinite recursion by requiring an array of length > 1.
  if ( arr.length < 2 )
    throw 'shuffleUnique() only accepts an array with at least two entries.'

  const a = shuffle( arr )

  // Tail call optimization.
  return !isEqual( a, arr ) ? a : shuffleUnique( arr )
}
/**
 * Shuffles and returns a new array in a different order than the original.
 *
 * WARNING: This function can cause infinite recursion if each entry
 * of the array passes an equality test. Be careful when using this.
 * Does the output NEED to be of different order than the input?
 */
Shuffles and returns a new array in a different order than the original.
WARNING: This function can cause infinite recursion if each entry
of the array passes an equality test. Be careful when using this.
Shuffles and returns a new array in a different order than the original . WARNING : This function can cause infinite recursion if each entry of the array passes an equality test . Be careful when using this .
function shuffleUnique( arr ) {
  if ( arr.length < 2 )
    throw 'shuffleUnique() only accepts an array with at least two entries.'
  const a = shuffle( arr )
  return !isEqual( a, arr ) ? a : shuffleUnique( arr )
}
function shuffleUnique ( arr ) { if ( arr . length < 2 ) throw 'shuffleUnique() only accepts an array with at least two entries.' const a = shuffle ( arr ) return ! isEqual ( a , arr ) ? a : shuffleUnique ( arr ) }
Shuffles and returns a new array in a different order than the original.
Shuffles and returns a new array in a different order than the original .
// Try to prevent infinite recursion by requiring an array of length > 1. // Tail call optimization.