MCPcopy Create free account
hub / github.com/Effect-TS/effect / seededRandom

Function seededRandom

packages/effect/src/workflow/Activity.ts:285–299  ·  view source on GitHub ↗
(seed: string)

Source from the content-addressed store, hash-verified

283
284// Mulberry32 seeded with a hash of `seed`.
285const seededRandom = (seed: string): RandomService.Random => {
286 let state = Hash.string(seed)
287 const nextDoubleUnsafe = () => {
288 state = (state + 0x6D2B79F5) | 0
289 let t = Math.imul(state ^ (state >>> 15), 1 | state)
290 t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
291 return ((t ^ (t >>> 14)) >>> 0) / 4294967296
292 }
293 return {
294 nextDoubleUnsafe,
295 nextIntUnsafe: () =>
296 Math.floor(nextDoubleUnsafe() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) +
297 Number.MIN_SAFE_INTEGER
298 }
299}
300
301/**
302 * Context reference containing the current activity retry attempt, defaulting

Callers 1

Activity.tsFile · 0.85

Calls 2

nextDoubleUnsafeFunction · 0.70
stringMethod · 0.45

Tested by

no test coverage detected