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

Function getRandomArrayElements

jd_summer_movement.js:612–621  ·  view source on GitHub ↗

* 随机从一数组里面取 * @param arr * @param count * @returns {Buffer}

(arr, count)

Source from the content-addressed store, hash-verified

610 * @returns {Buffer}
611 */
612function getRandomArrayElements(arr, count) {
613 var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
614 while (i-- > min) {
615 index = Math.floor((i + 1) * Math.random());
616 temp = shuffled[index];
617 shuffled[index] = shuffled[i];
618 shuffled[i] = temp;
619 }
620 return shuffled.slice(min);
621}
622function getAuthorShareCode(url) {
623 return new Promise(async resolve => {
624 const options = {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected