Skip to content
tsdotnetPublic

About

A utility for simplifying generating random numbers and shuffling arrays.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

@tsdotnet/random: Pick, mix and roll. Random numbers, picks and shuffles.

npm version GitHub license

Random numbers, integers in ranges, random picks and shuffles.

Install

npm install @tsdotnet/random

Usage

import random from '@tsdotnet/random';

const deck = [1, 2, 3, 4, 5];
random.integer(6);             // 0 to 5
random.next.inRange(10, 20);   // 10 to 19
random.select.one(deck);       // one random entry
random.shuffleCopy(deck);      // a new shuffled array
random.shuffle(deck);          // shuffles in place

random.integers(count, boundary) returns an array of random integers; random.select(source, n) picks n entries.

Use it from

ESM (import random from '@tsdotnet/random';) or CommonJS (const random = require('@tsdotnet/random').default;).

In a browser, without a bundler
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/array-init@1/dist/umd/array-init.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/exceptions@1/dist/umd/exceptions.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/array-copy@1/dist/umd/array-copy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/integer@1/dist/umd/integer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/random@1/dist/umd/random.min.js"></script>
<script>
  const random = tsdotnet.random.default;
</script>

Docs

tsdotnet.github.io/random

About

A utility for simplifying generating random numbers and shuffling arrays.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages