# @huteming/util-roller

> 提供区间概率算法

Latest version **4.0.0** (published 2020-02-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @huteming/util-roller
pnpm add @huteming/util-roller
yarn add @huteming/util-roller
bun add @huteming/util-roller
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2020-02-05 |
| First published | 2019-02-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 756.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | huteming |

## Links

- npm: https://www.npmjs.com/package/@huteming/util-roller
- npm.io page: https://npm.io/package/@huteming/util-roller

## Recent versions

- 4.0.0 (latest) — 2020-02-05
- 1.2.1-alpha.0 — 2019-02-18
- 1.1.2-alpha.0 — 2019-02-15
- 1.1.1-alpha.0 — 2019-02-14
- 1.1.0 — 2019-02-13
- 1.0.1 — 2019-02-13

## README

> 概率随机算法

-------------------

## 示例

```javascript
import { Roller } from '@huteming/util'

const roller = new Roller()

roller.add(value, rate)

const value = roller.done()
```

## 实例方法

`add` 方法并不要求所有的 `rate` 总和为 `100`。方法内部会根据各个 `rate` 所占比例作为概率

| name | 描述 | 参数 |
|----------|------------|-------------|
| add | 添加概率区间 | |
| done | 产生随机数，并返回对应 value | |

## add 参数

| name | 说明 | 类型 | 可选值 | 默认值 |
|-----------|------------|-------------|------------|-----------|
| value | 唯一标识符，内部不关心该数据，会在获取随机数后返回给外部 | Any | |
| rate | 占据比例, 任意数字 | Number | | |

---
_Source: https://npm.io/package/@huteming/util-roller · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
