# @reverse/random

> Easy random generation.

Latest version **1.0.12** (published 2019-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @reverse/random
pnpm add @reverse/random
yarn add @reverse/random
bun add @reverse/random
```

## 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 | 1.0.12 |
| Published | 2019-12-27 |
| First published | 2019-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | hparcells, imdaveead |
| Keywords | random, util, utility |

## Links

- npm: https://www.npmjs.com/package/@reverse/random
- Repository: https://github.com/reverse-squared/reverse-npm
- Homepage: https://github.com/reverse-squared/reverse-npm/tree/master/packages/reverse-random
- Issues: https://github.com/reverse-squared/reverse-npm/issues
- npm.io page: https://npm.io/package/@reverse/random

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2019-12-27
- 1.0.11 — 2019-12-27
- 1.0.10 — 2019-10-22
- 1.0.9 — 2019-08-08
- 1.0.8 — 2019-08-06
- 1.0.7 — 2019-08-04
- 1.0.6 — 2019-08-01
- 1.0.5 — 2019-07-31
- 1.0.4 — 2019-07-31
- 1.0.3 — 2019-07-31
- 1.0.2 — 2019-06-30
- 1.0.1 — 2019-06-24
- 1.0.0 — 2019-06-24

## README

# @reverse/random

> Easy random generation.

You can install with nodejs and npm

```
npm i @reverse/random
```

## Table of Contents

- [randomInt](#randomIntmin-max)
- [chance](#chancepercent)
- [randomOf](#randomOflist)
- [randomList](#randomListlist-items-requiredValues)

## Usage

### randomInt(min, max)

> Generates a random whole number between two values.

#### Parameters

- `min: Number`: The minimum number to generate inclusivly.
- `max: Number`: The maximum number to generate inclusivly.

#### Example

```js
import { randomInt } from '@reverse/random';

randomInt(1, 5);
// Example Output: 5
```

### chance(percent)

> Returns true a percent amount of the time.

#### Parameters

- `percent: Number`: The percent chance to return true.

#### Example

```js
import { chance } from '@reverse/random';

chance(100);
// true

chance(0);
// false

chance(50);
// Example Output: true
```

### randomOf(list)

> Returns a random element from an array.

#### Parameters

- `list: Array`: The array to pick from.

#### Example

```js
import { randomOf } from '@reverse/random';

randomOf([1, 2, 3]);
// Example Output: 2
```

### randomList(list, items, requiredValues)

> Picks multiple values from an array.

#### Parameters

- `list: Array`: The array to choose from.
- `items: Number`: How many items should be returned. Default 1.
- `requiredValues: Array`: The values that have to be in the returned items. Default [].

#### Example

```js
import { randomList } from '@reverse/random';

randomList([1, 2, 3, 4], 1, []);
// Exanple Output: [3]

randomList([1, 2, 3, 4], 2, []);
// Exanple Output: [1, 3]

randomList([1, 2, 3, 4], 3, [3]);
// Exanple Output: [3, 3, 3]
```

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