🌳
pt0/sharedF/moDashF/seededRandomF.mts
1import _lodash from 'lodash'
2import seedrandom from 'seedrandom'
3import type { LoDashStatic } from 'lodash'
5export { seedrandom }
7export const seedLodash = (seed: string): LoDashStatic => {
8 const orig = Math.random
9 seedrandom(seed, { global: true })
10 const lodash = _lodash.runInContext()
11 Math.random = orig
12 return lodash
15export const seededShuffle = <T,>(seed: string, arr: T[]): T[] => {
16 const seededLodash = seedLodash(seed)
17 return seededLodash.shuffle(arr)