3h-random 中文文档教程

发布于 6年前 浏览 26 项目主页 更新于 3年前

3h-random

可播种的随机发生器。

Usage

这个库可以在节点环境和浏览器环境中使用。 dist/index(.min).js定义了一个es模块,dist/index.umd(.min).js定义了一个umd模块。

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.

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.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文