MCPcopy Create free account
hub / github.com/6dylan6/jdm / randomArray

Method randomArray

function/magic.js:803–814  ·  view source on GitHub ↗
(arr, count)

Source from the content-addressed store, hash-verified

801 }
802
803 randomArray(arr, count) {
804 count = count || arr.length
805 let shuffled = arr.slice(0), i = arr.length, min = i - count, temp,
806 index;
807 while (i-- > min) {
808 index = Math.floor((i + 1) * Math.random());
809 temp = shuffled[index];
810 shuffled[index] = shuffled[i];
811 shuffled[i] = temp;
812 }
813 return shuffled.slice(min);
814 }
815
816 now(fmt) {
817 return format(Date.now(), fmt || 'yyyy-MM-dd HH:mm:ss.SSS')

Callers 2

runMethod · 0.95
isvObfuscatorMethod · 0.95

Calls 1

randomMethod · 0.45

Tested by

no test coverage detected