Skip to main content
Home

Built and signed on GitHub Actions

A module for generating random values.

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
100%
Published
a year ago (0.1.0)

A module for generating random values.

  • randomUUID() - creates a random universal unique identifier.
  • getRandomValues() - creates random values for the given array.
  • randomBytes() - creates a Uint8Array with random values (bytes) for the given length using a cryptographically secure random number generator (CSRNG).
  • randomFileName() - creates a random file name with the given length using CSRNG.

Basic Usage

import { randomBytes, randomFileName } from "@gnome/assert";

// returns a Uint8Array filled with random bytes
console.log(randomBytes(32))

// return a file name that starts with tmp_ followed by
// 15 random characters.
console.log(randomFileName(15, 'tmp_'))
Built and signed on
GitHub Actions

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.

Add Package

deno add jsr:@gnome/random

Import symbol

import * as random from "@gnome/random";
or

Import directly with a jsr specifier

import * as random from "jsr:@gnome/random";

Add Package

pnpm i jsr:@gnome/random
or (using pnpm 10.8 or older)
pnpm dlx jsr add @gnome/random

Import symbol

import * as random from "@gnome/random";

Add Package

yarn add jsr:@gnome/random
or (using Yarn 4.8 or older)
yarn dlx jsr add @gnome/random

Import symbol

import * as random from "@gnome/random";

Add Package

vlt install jsr:@gnome/random

Import symbol

import * as random from "@gnome/random";

Add Package

npx jsr add @gnome/random

Import symbol

import * as random from "@gnome/random";

Add Package

bunx jsr add @gnome/random

Import symbol

import * as random from "@gnome/random";