source: node_modules/d3-array/src/shuffle.js

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

Prototype 1.1

  • Property mode set to 100644
File size: 329 bytes
Line 
1export default shuffler(Math.random);
2
3export function shuffler(random) {
4 return function shuffle(array, i0 = 0, i1 = array.length) {
5 let m = i1 - (i0 = +i0);
6 while (m) {
7 const i = random() * m-- | 0, t = array[m + i0];
8 array[m + i0] = array[i + i0];
9 array[i + i0] = t;
10 }
11 return array;
12 };
13}
Note: See TracBrowser for help on using the repository browser.