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

Function randomIntBetween

packages/effect/src/Crypto.ts:255–262  ·  view source on GitHub ↗
(min, max, options)

Source from the content-addressed store, hash-verified

253 randomInt: Effect.sync(() => nextIntUnsafe()),
254 randomBetween: (min, max) => Effect.sync(() => nextDoubleUnsafe() * (max - min) + min),
255 randomIntBetween(min, max, options) {
256 const extra = options?.halfOpen === true ? 0 : 1
257 return Effect.sync(() => {
258 const minInt = Math.ceil(min)
259 const maxInt = Math.floor(max)
260 return Math.floor(nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt
261 })
262 },
263 randomShuffle: (elements) =>
264 Effect.sync(() => {
265 const buffer = Array.from(elements)

Callers

nothing calls this directly

Calls 2

nextDoubleUnsafeFunction · 0.70
syncMethod · 0.45

Tested by

no test coverage detected