# random-int-array

> Returns an array of random integers, with the option of having them be unique.

Latest version **1.0.0** (published 2016-01-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install random-int-array
pnpm add random-int-array
yarn add random-int-array
bun add random-int-array
```

## 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.0 |
| Published | 2016-01-09 |
| First published | 2016-01-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zachary Sloss |
| Maintainers | zsloss |
| Keywords | random, integer, int, array, unique |

## Links

- npm: https://www.npmjs.com/package/random-int-array
- Repository: https://github.com/zsloss/random-int-array
- Homepage: https://github.com/zsloss/random-int-array#readme
- Issues: https://github.com/zsloss/random-int-array/issues
- npm.io page: https://npm.io/package/random-int-array

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-01-09

## README

# random-int-array

Returns an array of random integers, with the option of having them be unique.

## Node.js Installation

```
$ npm install random-int-array
```
Or, simply include random-int-array.js in your web app.

## Usage

```javascript
var randomIntArray = require('random-int-array');

var myRandomIntArray = randomIntArray(options);
```

`options` is an object that should contain the following members:
* `count` - the number of integers in the array
* `min` - the inclusive lower bound for each random integer (defaults to 0 if not supplied)
* `max` - the exclusive upper bound for each random integer
* `unique` - set to true to ensure that all integers in the array are unique - `count` will shrink to the `min` and `max` range if it is greater (defaults to false if not supplied)

### Examples

```javascript
var randomIntArray = require('random-int-array');

randomIntArray({ count: 10, max: 100 });
// Returns an array of 10 integers between 0 and 99

randomIntArray({ count: 3, min: 3, max: 11 });
// Returns an array of 3 integers between 3 and 10.

randomIntArray({ count: 10, max: 101, unique: true });
// Returns an array of 10 integers between 0 and 100, with no duplicates.
```

## Performance Note

When uniqueness is required, one of two different algorithms is selected. Each algorithm performs badly depending on the values supplied for `count` and the range between `min` and `max`. After a bit of testing, I found that I should switch functions when the `count` is about 16% of the `max`-`min` range, so that the best-performing algorithm is used.

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