Skip to main content
Home

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

Works with
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 Score94%
Downloads18/wk
Published2 months ago (0.1.5)

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

function randomBetween
Unstable
randomBetween(
min: number,
max: number,
options?: RandomOptions
): number

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

The number is in the range [min, max), i.e. min is included but max is excluded.

Examples

Usage

import { randomBetween } from "@std/random";

randomBetween(1, 10); // 6.688009464410508
randomBetween(1, 10); // 3.6267118101712006
randomBetween(1, 10); // 7.853320239013774

Parameters

The minimum value (inclusive)

The maximum value (exclusive)

optional
options: RandomOptions

The options for the random number generator

Return Type

A random number between the provided minimum and maximum values

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.

Add Package

deno add jsr:@std/random

Import symbol

import { randomBetween } from "@std/random/between";
or

Import directly with a jsr specifier

import { randomBetween } from "jsr:@std/random/between";