Function shuffle

Returns a shuffled copy of the input array.

import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

const d = [1, 2, 3, 4];
const s = Arrays.shuffle(d);
// d: [1, 2, 3, 4], s: [3, 1, 2, 4]
  • Type Parameters

    • V

      Type of array items

    Parameters

    • dataToShuffle: readonly V[]
    • rand: RandomSource = Math.random

      Random generator. Math.random by default.

    Returns V[]

    Copy with items moved around randomly