MCPcopy
hub / github.com/spicetify/cli / shuffle

Function shuffle

Extensions/shuffle+.js:500–518  ·  view source on GitHub ↗
(array)

Source from the content-addressed store, hash-verified

498 }
499
500 function shuffle(array) {
501 let counter = array.length;
502 if (counter <= 1) return array;
503
504 // While there are elements in the array
505 while (counter > 0) {
506 // Pick a random index
507 const index = Math.floor(Math.random() * counter);
508
509 // Decrease counter by 1
510 counter--;
511
512 // And swap the last element with it
513 const temp = array[counter];
514 array[counter] = array[index];
515 array[index] = temp;
516 }
517 return array.filter(Boolean);
518 }
519
520 async function Queue(list, context, type) {
521 const count = list.length;

Callers 1

fetchAndPlayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected