Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/handipriyono/simple-number-generator
simple random number generator - https://www.npmjs.com/package/simple-random-number-generator
https://github.com/handipriyono/simple-number-generator
generator javascript nodejs random
Last synced: about 12 hours ago
JSON representation
simple random number generator - https://www.npmjs.com/package/simple-random-number-generator
- Host: GitHub
- URL: https://github.com/handipriyono/simple-number-generator
- Owner: handipriyono
- License: mit
- Created: 2019-08-24T00:30:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T15:43:03.000Z (almost 2 years ago)
- Last Synced: 2024-12-28T21:47:49.146Z (13 days ago)
- Topics: generator, javascript, nodejs, random
- Language: JavaScript
- Homepage:
- Size: 266 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/simple-random-number-generator)](https://www.npmjs.com/package/simple-random-number-generator)
[![build with travis CI](https://img.shields.io/travis/handipriyono/simple-number-generator/master)](https://travis-ci.org/handipriyono/simple-number-generator)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)---
# Simple Random Number Generator
# install
`npm install simple-random-number-generator`
# usage
```javascript
const random = require("simple-random-number-generator");
```## default options
the exported function takes an option **object** with 3 arguments:
- `min` : smallest possible value to return. defaults to 0
- `max` : largest possible value to return. defaults to 1
- `integer` : round the random number. Default: false### Examples
```javascript
// use min and max parameter
const random = require("simple-random-number-generator");
let params = {
min: 10,
max: 100
};
random(params); // example outputs → 89.67405538799946
``````javascript
// use min, max and integer parameter
// set integer to true to return whole number instead of float.
const random = require("simple-random-number-generator");
let params = {
min: 5,
max: 76,
integer: true
};
random(params); // example outputs → 68
```- only use `min` parameter
```javascript
let random = require("simple-random-number-generator");
let params = {
min: 988
};
// if only provide min parameter, max number will be min + 1
random(params); // example output → 988.9231522653375
```- only use `max` parameter
```javascript
let random = require("simple-random-number-generator");
let params = {
max: 200
};
//if only provide max parameter, Min number will be max - 1
random(params); // example output → 199.28545186511627
```