MCPcopy Create free account
hub / github.com/CammyLeone/devious-buttplug / selectRandomSlice

Function selectRandomSlice

goon-client/src/AsyncGoon.js:4–13  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

2
3const selectRandom = (array) => array[Math.floor(Math.random() * array.length)];
4const selectRandomSlice = (size) => (array) => {
5 const slice = [];
6 while (slice.length < size && slice.length < array.length) {
7 const toSelect = selectRandom(array);
8 if (!slice.includes(toSelect)) {
9 slice.push(toSelect);
10 }
11 }
12 return slice;
13};
14
15class AsyncGoon extends React.Component {
16 constructor(props) {

Callers 1

preloadSomeMoreMethod · 0.85

Calls 1

selectRandomFunction · 0.70

Tested by

no test coverage detected