MCPcopy Create free account
hub / github.com/Semporia/Scripts / getRandomArrayElements

Function getRandomArrayElements

jd_senbeans.js:209–218  ·  view source on GitHub ↗
(arr, count)

Source from the content-addressed store, hash-verified

207}
208
209function getRandomArrayElements(arr, count) {
210 var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
211 while (i-- > min) {
212 index = Math.floor((i + 1) * Math.random());
213 temp = shuffled[index];
214 shuffled[index] = shuffled[i];
215 shuffled[i] = temp;
216 }
217 return shuffled.slice(min);
218}
219
220async function help() {
221 await new Promise((resolve) => {

Callers 1

jd_senbeans.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected