# node-random

> random.org client

Latest version **1.0.1** (published 2016-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-random
pnpm add node-random
yarn add node-random
bun add node-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.1 |
| Published | 2016-04-18 |
| First published | 2013-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Mark Old |
| Maintainers | dlom |
| Keywords | random, random.org |

## Links

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

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.34.0
- [random-ua](https://npm.io/package/random-ua.md) 0.0.6

## Recent versions

- 1.0.1 (latest) — 2016-04-18
- 1.0.0 — 2014-04-16
- 0.0.3 — 2013-07-31
- 0.0.2 — 2013-01-02
- 0.0.1 — 2013-01-02

## README

# node-random [![Build Status](https://travis-ci.org/dlom/node-random.svg?branch=master)](https://travis-ci.org/dlom/node-random)

A [random.org](https://www.random.org) API client

## Install

`npm install node-random`

## Usage

The `options` argument is always optional.

`numbers` is an alias for `integers`

`sequence` is an alias for `sequences`

```javascript
var random = require("node-random");

random.integers(options, function(error, data) {
    // data is an array of numbers
});

random.sequences(options, function(error, quota) {
    // data is an array of numbers
});

random.strings(options, function(error, data) {
    // data is an array of strings
});

random.quota(options, function(error, data) {
    // data is an integer
});
```

## Options Defaults

### `random.integers`

See [here](http://www.random.org/clients/http/#integers) for the meanings (Option names are slightly different);

* `number` - `1`
* `minimum` - `0`
* `maximum` - `10000`
* `columns` - `1` (When this is more than 1, `data` is a 2D array -- rows by columns)
* `base` - `10`
* `random` - `"new"`

### `random.sequences`

See [here](http://www.random.org/clients/http/#sequences) for the meanings (Option names are slightly different);

* `minimum` - `0`
* `maximum` - `10`
* `columns` - `1` (When this is more than 1, `data` is a 2D array -- rows by columns)
* `base` - `10`
* `random` - `"new"`

### `random.strings`

See [here](http://www.random.org/clients/http/#strings) for the meanings (Option names are slightly different);

* `number` - `1`
* `length` - `10`
* `digits` - `true`
* `upper` - `true`
* `lower` - `true`
* `unique` - `false`
* `random` - `"new"`

### `random.quota`

See [here](http://www.random.org/clients/http/#quota) for the meanings (Option names are slightly different);

* `ip` - `""`

## Examples

```javascript
var random = require("node-random");

// Get 2 random numbers between 1 and 6
console.log("Rolling 2 dice");
random.numbers({
    "number": 2,
    "minimum": 1,
    "maximum": 6
}, function(error, data) {
    if (error) throw error;
    data.forEach(function(d) {
        console.log(d);
    });
});

// Get a random 3x3 grid and print the middle vertical row
random.sequences({
    "minimum": 1,
    "maximum": 9,
    "columns": 3
}, function(error, data) {
    if (error) throw error;
    console.log(data);
    console.log(data[0][1]);
    console.log(data[1][1]);
    console.log(data[2][1]);
});

// Get 20 different lowercase characters
random.strings({
    "length": 1,
    "number": 20,
    "upper": false,
    "digits": false
}, function(error, data) {
   if (error) throw error;
   console.log(data.join(" and "));
});

// Check your quota
random.quota(function(error, quota) {
    console.log("Remaining bytes: " + quota)
});
```

## Aliases

* `random.numbers` = `random.integers`
* `random.sequence` = `random.sequences`
* `random.string` = `random.strings`

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