Skip to main content
Home

@std/random@0.1.4
Built and signed on GitHub Actions

UNSTABLE: Various utilities using random number generators. The package also provides seeded pseudo-random number generator.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
a month ago (0.1.4)

default

Utilities for generating random numbers.

f
getRandomValuesSeeded

Creates a pseudo-random value generator that populates typed arrays, based on the given seed. The algorithm used for generation is PCG32.

f
nextFloat64

Get a float64 in the range [0, 1) from a random value generator.

f
randomBetween

Generates a random number between the provided minimum and maximum values.

f
randomIntegerBetween

Generates a random integer between the provided minimum and maximum values.

f
randomSeeded

Creates a pseudo-random number generator that generates random numbers in the range [0, 1), based on the given seed, with 32 bits of entropy. The algorithm used for generation is PCG32.

f
sample

Returns a random element from the given array.

T
SampleOptions

Options for sample.

f
shuffle

Shuffles the provided array, returning a copy and without modifying the original array.

T
Prng

A pseudo-random number generator implementing the same contract as Math.random, i.e. taking zero arguments and returning a random number in the range [0, 1). The behavior of a function that accepts a Prng an option may be customized by passing a Prng with different behavior from Math.random, for example it may be seeded.

f
randomBetween

Generates a random number between the provided minimum and maximum values.

T
RandomOptions

Options for random number generation.

f
getRandomValuesSeeded

Creates a pseudo-random value generator that populates typed arrays, based on the given seed. The algorithm used for generation is PCG32.

T
IntegerTypedArray

An integer typed array

T
RandomValueGenerator

A pseudo-random number generator implementing the same contract as crypto.getRandomValues, i.e. taking a typed array and mutating it by filling it with random bytes, returning the mutated typed array instance.

f
randomIntegerBetween

Generates a random integer between the provided minimum and maximum values.

f
nextFloat64

Get a float64 in the range [0, 1) from a random value generator.

f
sample

Returns a random element from the given array.

T
SampleOptions

Options for sample.

f
randomSeeded

Creates a pseudo-random number generator that generates random numbers in the range [0, 1), based on the given seed, with 32 bits of entropy. The algorithm used for generation is PCG32.

f
shuffle

Shuffles the provided array, returning a copy and without modifying the original array.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.