1.0.8 • Published 4 years ago

@cspruit/serendipity v1.0.8

Weekly downloads
10
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

Build Status codecov npm license XO code style Greenkeeper badge

Serendipity

Math.random() for the rest of us.

Serendipity is a javascript library that generates custom random numbers.

Note that this currently just uses Math.random() for psuedo-random generation. If you need closer to true random, there are plenty of libraries made by people who know their stuff far better. 😉 This was created because I was sick of creating the same random function over and over again.

Installation

  • Install by running npm install --save-dev @cspruit/serendipity in the same directory as the package.json file lives.

Usage

Random

  • Generates a random number based off of Math.random
    • max : number - optional - Max range, exclusive.
    • min : number - optional - Min range, inclusive
    • useFractions - optional - Unless this is true, will return an integer
import {random} from '@cspruit/serendipity';

const randNormal = random(); // Returns 0-1, like Math.random()
const randMax = random(5); // Returns 0-4
const randMin = random(5, 1); // Returns 1-4
const randFloat = random(5, 1, true); // Returns a float from 1-4

Contributing

All contributions, suggestions, and issues are welcome!

Check out the Issues page. In general anything listed is up for grabs, though bugs tend to be more detailed than enhancements and might be better to pick up if starting out.

License

This project uses GPL 3.0.

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago