3h-random

A seedable randomizer.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
10Aug 2, 2018Jul 7, 2018Minified + gzip package size for 3h-random in KB

Readme

3h-random

A seedable randomizer.

Usage

This lib can be used in both node environment and browser environment. dist/index(.min).js defines an es module, and dist/index.umd(.min).js defines a umd module.

Example

// The export object itself is an instance
// of Randomizer which is seeded by Date.now().
console.log(Random.float());
// You can create your own randomizer via the
// exported constructor.
const randomizer = new Random.Randomizer(seed);

APIs

  • Randomizer
    • seed number - The seed of the randomizer.
    • cursor number - The cursor.
    • float(min = 0, max = 1) number - Get a random float in (min, max).
    • int(min = 1, max = 100) number - Get an random integer in [min, max].
    • boolean() boolean - Get a random boolean value.
    • string(radix = 16, upperCase = true) string - Get a random string.
    • element<T>(arrayLike: ArrayLike<T>) T - Get a random element.
    • reset(seed?: number) this - Reset the randomizer.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.