source: node_modules/es-toolkit/dist/array/shuffle.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 634 bytes
Line 
1/**
2 * Randomizes the order of elements in an array using the Fisher-Yates algorithm.
3 *
4 * This function takes an array and returns a new array with its elements shuffled in a random order.
5 *
6 * @template T - The type of elements in the array.
7 * @param {T[]} arr - The array to shuffle.
8 * @returns {T[]} A new array with its elements shuffled in random order.
9 *
10 * @example
11 * const array = [1, 2, 3, 4, 5];
12 * const shuffledArray = shuffle(array);
13 * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
14 */
15declare function shuffle<T>(arr: readonly T[]): T[];
16
17export { shuffle };
Note: See TracBrowser for help on using the repository browser.