MCPcopy Create free account
hub / github.com/breck7/scroll / shuffleInPlace

Method shuffleInPlace

external/.scrollLibs.js:14192–14200  ·  view source on GitHub ↗
(arr, seed = Date.now())

Source from the content-addressed store, hash-verified

14190 return parts.join("/")
14191 }
14192 static shuffleInPlace(arr, seed = Date.now()) {
14193 // https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array
14194 const randFn = Utils._getPseudoRandom0to1FloatGenerator(seed)
14195 for (let index = arr.length - 1; index > 0; index--) {
14196 const tempIndex = Math.floor(randFn() * (index + 1))
14197 ;[arr[index], arr[tempIndex]] = [arr[tempIndex], arr[index]]
14198 }
14199 return arr
14200 }
14201 // Only allows a-zA-Z0-9-_ (And optionally .)
14202 static _permalink(str, reg) {
14203 return str.length ? str.toLowerCase().replace(reg, "").replace(/ /g, "-") : ""

Callers

nothing calls this directly

Tested by

no test coverage detected