# @ts-pro/unique-random-number

> Fast & simple unique random numbers generator

Latest version **1.0.4** (published 2021-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ts-pro/unique-random-number
pnpm add @ts-pro/unique-random-number
yarn add @ts-pro/unique-random-number
bun add @ts-pro/unique-random-number
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-07-09 |
| First published | 2021-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Oleksandr Havrashenko |
| Maintainers | havrashenko |

## Links

- npm: https://www.npmjs.com/package/@ts-pro/unique-random-number
- Repository: https://github.com/ts-pro/unique-random-number
- Issues: https://github.com/ts-pro/unique-random-number/issues
- npm.io page: https://npm.io/package/@ts-pro/unique-random-number

## Recent versions

- 1.0.4 (latest) — 2021-07-09
- 1.0.3 — 2021-07-01

## README

# Unique Random Number

### Fast & simple unique random numbers generator

This lib can generate unique numbers for big ranges. It's very simple in usage, just check it out.

## Installation

npm:
```sh
npm install @ts-pro/unique-random-number
```
yarn:
```sh
yarn add @ts-pro/unique-random-number
```

## Usage

Simple example of usage.

```js
import { UniqueRandomNumber } from 'unique-random-number';
const unique = new UniqueRandomNumber(0, 1000000);

console.log(unique.get()); // Will print unique random number in 0 ... 1000000 ( inclusive )
```

What will happen if random numbers reach the end ?
```js
import { UniqueRandomNumber } from 'unique-random-number';
const unique = new UniqueRandomNumber(0, 2);

console.log(unique.get()); // Will print 0 or 1 or 2
console.log(unique.get()); // Will print 0 or 1 or 2
console.log(unique.get()); // Will print 0 or 1 or 2
console.log(unique.get()); // Will print undefined which means that we have riched the end
```

You can work with iterators ( this loop will end when it riches last number, you don't have to write any conditions ):
```js
import { UniqueRandomNumber } from 'unique-random-number';
const unique = new UniqueRandomNumber(0, 100);

for(let n of unique) {
  console.log(n); // Will print numbers between 0 ... 100
}
```

You can use random number inside strings ( from v1.0.4 ):
```js
import { UniqueRandomNumber } from 'unique-random-number';
const unique = new UniqueRandomNumber();

console.log(`Unique random number: ${unique}`); // Will print specified string with unique random number inside
```

## License

Unique random number is [MIT-licensed](LICENSE) open-source software by [Oleksandr Havrashenko](https://github.com/gavrashenko).

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