Skip to main content Link Search Menu Expand Document (external link)

TRandom.ts overview

Since v2.0.0


Exports Grouped by Category


context

Tag

The service tag used to access TRandom in the environment of an effect.

Signature

declare const Tag: Context.Tag<TRandom, TRandom>

Source

Since v2.0.0

live

The “live” TRandom service wrapped into a Layer.

Signature

declare const live: Layer.Layer<TRandom, never, never>

Source

Since v2.0.0

models

TRandom (interface)

Signature

export interface TRandom {
  readonly [TRandomTypeId]: TRandomTypeId
  /**
   * Returns the next numeric value from the pseudo-random number generator.
   */
  readonly next: STM.STM<number>
  /**
   * Returns the next boolean value from the pseudo-random number generator.
   */
  readonly nextBoolean: STM.STM<boolean>
  /**
   * Returns the next integer value from the pseudo-random number generator.
   */
  readonly nextInt: STM.STM<number>
  /**
   * Returns the next numeric value in the specified range from the
   * pseudo-random number generator.
   */
  nextRange(min: number, max: number): STM.STM<number>
  /**
   * Returns the next integer value in the specified range from the
   * pseudo-random number generator.
   */
  nextIntBetween(min: number, max: number): STM.STM<number>
  /**
   * Uses the pseudo-random number generator to shuffle the specified iterable.
   */
  shuffle<A>(elements: Iterable<A>): STM.STM<Array<A>>
}

Source

Since v2.0.0

random

next

Returns the next number from the pseudo-random number generator.

Signature

declare const next: STM.STM<number, never, TRandom>

Source

Since v2.0.0

nextBoolean

Returns the next boolean value from the pseudo-random number generator.

Signature

declare const nextBoolean: STM.STM<boolean, never, TRandom>

Source

Since v2.0.0

nextInt

Returns the next integer from the pseudo-random number generator.

Signature

declare const nextInt: STM.STM<number, never, TRandom>

Source

Since v2.0.0

nextIntBetween

Returns the next integer in the specified range from the pseudo-random number generator.

Signature

declare const nextIntBetween: (low: number, high: number) => STM.STM<number, never, TRandom>

Source

Since v2.0.0

nextRange

Returns the next number in the specified range from the pseudo-random number generator.

Signature

declare const nextRange: (min: number, max: number) => STM.STM<number, never, TRandom>

Source

Since v2.0.0

shuffle

Uses the pseudo-random number generator to shuffle the specified iterable.

Signature

declare const shuffle: <A>(elements: Iterable<A>) => STM.STM<Array<A>, never, TRandom>

Source

Since v2.0.0

symbols

TRandomTypeId

Signature

declare const TRandomTypeId: unique symbol

Source

Since v2.0.0

TRandomTypeId (type alias)

Signature

type TRandomTypeId = typeof TRandomTypeId

Source

Since v2.0.0