rejection-sampled-int
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

rejection-sampled-int

Build Status npm install js-standard-style

Cryptographically random integers, chosen by a rejection sampling algorithm.

Warning: I am not a cryptographer, or any sort of random number expert. An audit would be greatly appreciated.

Installation

To install the module for use in your projects:

npm install rejection-sampled-int

This library includes TypeScript definitions, and should be discovered automatically by the TypeScript compiler.

Usage

var rand = require('rejection-sampled-int')
 
rand.sync({max: 128}) // 56
rand.sync({min: 10, max: 16}) // 11
rand({min: 10, max: 16}, (err, int) => int) // 13
rand({min: 10, max: 16}).then(int => int) // 10
rand.sync() // 8882371922968183

API

  • rand({min = 0, max = Number.MAX_SAFE_INT}, [ready(err, int)]) Get an integer between min (inclusive) and max (exclusive). If ready is not provided, a Promise is returned.
  • rand.sync({min = 0, max = Number.MAX_SAFE_INT}) Get an integer between min (inclusive) and max (exclusive), synchronously.

License

MIT. See LICENSE for details.

Readme

Keywords

Package Sidebar

Install

npm i rejection-sampled-int

Weekly Downloads

30

Version

0.4.0

License

MIT

Unpacked Size

13.7 kB

Total Files

9

Last publish

Collaborators

  • fardog