# rand-ms

> Get pseudo-random millisecond values for timeouts/intervals

Latest version **1.1.1** (published 2022-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install rand-ms
pnpm add rand-ms
yarn add rand-ms
bun add rand-ms
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-07-07 |
| First published | 2022-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Christopher McCulloh |
| Maintainers | cmcculloh |
| Keywords | milliseconds, random, timeout |

## Links

- npm: https://www.npmjs.com/package/rand-ms
- Repository: https://github.com/cmcculloh/rand-ms
- Homepage: https://github.com/cmcculloh/rand-ms#readme
- Issues: https://github.com/cmcculloh/rand-ms/issues
- npm.io page: https://npm.io/package/rand-ms

## Recent versions

- 1.1.1 (latest) — 2022-07-07
- 1.1.0 — 2022-04-19
- 1.0.2 — 2022-04-19
- 1.0.1 — 2022-04-18

## README

# rand-ms

> Get pseudo-random millisecond values for timeouts/intervals

## Install

```sh
npm install rand-ms
```

## Usage

```js
import randMS from 'rand-ms';

randMS(); // random ms between 0 & 10 seconds
//=> 6712

randMS(1); // random ms between 0 & 1 seconds
//=> 992

randMS(1, 4); // random ms between 1 & 4 seconds
//=> 3493

randMS('1ms', 4); // random ms between 1 ms & 4 s
//=> 2

randMS(1, '4seconds'); // random ms between 1 & 4 s
//=> 2351

randMS('1m', '4minutes'); // random ms between 1 & 4 minutes
//=> 80351

randMS('1h', '4hours'); // random ms between 1 & 4 hours
//=> 3640039

randMS('1d', '4days'); // random ms between 1 & 4 days
//=> 86482659

randMS('1w', '4weeks'); // random ms between 1 & 4 weeks
//=> 604800000

randMS('1M', '4months'); // random ms between 1 & 4 months
//=> 604800000

randMS('1y', '4years'); // random ms between 1 & 4 years
//=> 31557600000
```

## API

### randMS(min|max?, max?)

#### min|max

Type: `integer|string`
Default: `10`

If max is provided, this is the minimum number of seconds you would like represented as milliseconds. If no max is provided, this is assumed to be the maximum, and the minimum is set to 0.

#### max

Type: `integer|string`
Default: `undefined`

Maximum number of seconds you would like represented as milliseconds. If `undefined` or `null`, will be ignored and first parameter will be used for maximum.

#### string format

The string format for the time interval value of what you are passing in for min/max is a number followed immediately by any of the following:

`ms`, `s`, `m`, `h`, `d`, `w`, `M`, `y`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, `years`

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