0.2.0 • Published 5 years ago

random-value-generator v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

random-value-generator

Badges

Join Discord to chat! MIT License View package on npm Download package with npm Node.js compatibility View build on Travis Star project on GitHub

random-value-generator

Introduction

A simple, zero-dependency package that can generate random* values.

*: This package does NOT provide cryptographically secure random value generation!

List of functions

- randomNumber(max);
- randomInteger(max);
- randomBoolean();
- randomString(len);
- randomHash(len);
- randomEmoji();

Please note that max is the maximum value of the returned number, and len is the length of the returned string. Both kinds of parameters MUST be numbers.

For the Web

UNPKG can be used as CDN to deliver the script.

Loading the script:

<script src="http://unpkg.com/random-value-generator/index.js"></script>

Alternatively, script utilizing ES Module can be used:

<script type="module" src="http://unpkg.com/random-value-generator/index.mjs"></script>

Installation

Install the module with your terminal/console using:

npm i random-value-generator

Defining the module in your code:

  • CommonJS:
    const random = require("random-value-generator");
  • ES:
    import random from "random-value-generator/index.mjs";

Examples

Try the online demo.

/**
 * Logs a random number.
 */
console.log(random.randomNumber(max));

/**
 * Logs a random integer.
 */
console.log(random.randomInteger(max));

/**
 * Logs a random boolean. - true or false
 */
console.log(random.randomBoolean());

/**
 * Logs a random string consisting alphanumeric and special characters.
 */
console.log(random.randomString(len));

/**
 * Logs a random string consisting alphanumeric characters.
 */
console.log(random.randomHash(len));

/**
 * Logs a random emoji.
 */
console.log(random.randomEmoji());

API Documentations

View API documentations.

Changelog

View changelog.

Building from Source

View build instructions.

Links

NPM: https://www.npmjs.com/package/random-value-generator
Discord: https://discord.gg/QgxZuHk

License

This project is licensed under MIT License.

Copyright (c) 2019 vanished

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago