Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as mod from "https://git.sr.ht/~ruivieira/deno-experiments/blob/master/randomjs/mod.ts";

§Classes

MersenneTwister19937

An Engine that is a pseudorandom number generator using the Mersenne Twister algorithm based on the prime 2**19937 − 1

Random

A wrapper around an Engine that provides easy-to-use methods for producing values based on known distributions

§Variables

browserCrypto

An Engine that relies on the globally-available crypto.getRandomValues, which is typically available in modern browsers.

nativeMath

An int32-producing Engine that uses Math.random()

§Functions

bool

Returns a boolean Distribution with 50% probability of being true or false

createEntropy

Returns an array of random int32 values, based on current time and a random number engine

date

Returns a Distribution that returns a random Date within the inclusive range of [start, end].

dice

Returns a distribution that returns an array of length dieCount of values within [1, sideCount]

die

Returns a Distribution to return a value within [1, sideCount]

hex

Returns a Distribution that returns a random string comprised of numbers or the characters abcdef (or ABCDEF) of length length.

int32

Returns a value within [-0x80000000, 0x7fffffff]

int53

Returns a value within [-0x20000000000000, 0x1fffffffffffff]

int53Full

Returns a value within [-0x20000000000000, 0x20000000000000]

integer

Returns a Distribution to return a value within [min, max]

pick

Returns a random value within the provided source within the sliced bounds of begin and end.

picker

Returns a Distribution to random value within the provided source within the sliced bounds of begin and end.

real

Returns a floating-point value within [min, max) or [min, max]

realZeroToOneExclusive

Returns a floating-point value within [0.0, 1.0)

realZeroToOneInclusive

Returns a floating-point value within [0.0, 1.0]

sample

From the population array, produce an array with sampleSize elements that are randomly chosen without repeats.

shuffle

Shuffles an array in-place

string

Returns a distribution that returns a random string using numbers, uppercase and lowercase letters, _, and - of length length.

uint32

Returns a value within [0, 0xffffffff]

uint53

Returns a value within [0, 0x1fffffffffffff]

uint53Full

Returns a value within [0, 0x20000000000000]

uuid4

Returns a Universally Unique Identifier Version 4.

§Interfaces

Engine

A mechanism to retrieve random int32 values

§Type Aliases

Distribution

A function to use an Engine to produce a value

StringDistribution

A function to use an Engine to produce a string of a requested length