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

Random overview

Added in v2.0.0


Table of contents


constructors

next

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

Signature

export declare const next: Effect.Effect<number, never, never>

Added in v2.0.0

nextBoolean

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

Signature

export declare const nextBoolean: Effect.Effect<boolean, never, never>

Added in v2.0.0

nextInt

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

Signature

export declare const nextInt: Effect.Effect<number, never, never>

Added in v2.0.0

nextIntBetween

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

Signature

export declare const nextIntBetween: (min: number, max: number) => Effect.Effect<number>

Added in v2.0.0

nextRange

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

Signature

export declare const nextRange: (min: number, max: number) => Effect.Effect<number>

Added in v2.0.0

randomWith

Retreives the Random service from the context and uses it to run the specified workflow.

Signature

export declare const randomWith: <A, E, R>(f: (random: Random) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>

Added in v2.0.0

shuffle

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

Signature

export declare const shuffle: <A>(elements: Iterable<A>) => Effect.Effect<Chunk.Chunk<A>, never, never>

Added in v2.0.0

context

Random

Signature

export declare const Random: Context.Tag<Random, Random>

Added in v2.0.0

models

Random (interface)

Signature

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

Added in v2.0.0

symbols

RandomTypeId

Signature

export declare const RandomTypeId: typeof RandomTypeId

Added in v2.0.0

RandomTypeId (type alias)

Signature

export type RandomTypeId = typeof RandomTypeId

Added in v2.0.0