2.1.2 • Published 4 years ago

@dmhtoo/random-int v2.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

Random integer

Generate a random integer in Javascript (ES6), within a given range

This package is compatible with Typescript

Installation

npm install random-int --save

or

yarn add random-int


Syntax

randomInt(low, high);

Parameters

  • low: Optional minimum value (included). This defaults to 1.
  • high: Optional maximum value (included). This defaults to 100.

Return value

  • randomInt will return a randomly generated Integer, including the low and high limits.

Usage

Import the randomInt function

import { randomInt } from "@dmhtoo/random-int";

or

const { randomInt } = require("@dmhtoo/random-int")

Sample implementations

// Returns a random integer between default limits of 1 and 100, inclusive.
const myRandomInteger = randomInt();

// Returns a random integer between 1 and 10, inclusive.
const myRandomInteger = randomInt(1, 10);

References

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago