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

Function nextIntBetween

packages/effect/src/Random.ts:177–186  ·  view source on GitHub ↗
(min: number, max: number, options?: {
  readonly halfOpen?: boolean
})

Source from the content-addressed store, hash-verified

175 * @since 2.0.0
176 */
177export const nextIntBetween = (min: number, max: number, options?: {
178 readonly halfOpen?: boolean
179}): Effect.Effect<number> => {
180 const extra = options?.halfOpen === true ? 0 : 1
181 return randomWith((r) => {
182 const minInt = Math.ceil(min)
183 const maxInt = Math.floor(max)
184 return Math.floor(r.nextDoubleUnsafe() * (maxInt - minInt + extra)) + minInt
185 })
186}
187
188/**
189 * Uses the pseudo-random number generator to shuffle the specified iterable.

Callers

nothing calls this directly

Calls 2

randomWithFunction · 0.85
nextDoubleUnsafeMethod · 0.65

Tested by

no test coverage detected