MCPcopy Create free account
hub / github.com/codecombat/codecombat / deterministicShuffleForUserAndDay

Function deterministicShuffleForUserAndDay

ozaria/site/common/utils.js:17–35  ·  view source on GitHub ↗
(user, originalArray)

Source from the content-addressed store, hash-verified

15}
16
17export function deterministicShuffleForUserAndDay (user, originalArray) {
18 if (originalArray.length < 2) return originalArray
19 const rand = new RandomSeed(`${getDateString()}${user.id}`)
20
21 let shuffledArray, array
22 do {
23 shuffledArray = []
24 array = _.cloneDeep(originalArray)
25 while (array.length > 0) {
26 const element = rand.range(array.length)
27
28 shuffledArray.push(
29 array.splice(element, 1)[0]
30 )
31 }
32 } while (_.isEqual(shuffledArray, originalArray))
33
34 return shuffledArray
35}
36
37export function getDisplayPermission (permission) {
38 const display = permission?.toLowerCase()

Callers

nothing calls this directly

Calls 1

getDateStringFunction · 0.85

Tested by

no test coverage detected