Easy random is a bunch of simple random functions that I've gotten sick of rewriting in basically every npm package. No one likes dependencies so this doesn't have any. Well okay there are 3 dev dependencies for testing, but you don't have to install those in production, lucky you.
Readme's always have installation instructions so why would this one be any different.
$ npm install @remibutler/easyrandom
If you want to use this in production, and you should because it's better than your package, use the --production arg so you wont get any dev-dependencies installed.
$ npm ci @remibutler/easyrandom --production
Testing is done with:
This is simply because they're both very easy to use and hyper obvious, also they're basically mocha and chai, wait why don't we just use mo-
$ npm ci$ npm test
const easyRandom = ;const coin = easyRandom;
Full list of functions and their expected returns, there are jsdocs but you might wanna use runkit on npmjs so... here ya go!
Returns true or false randomly
easyRandom // true or false
Returns a psuedorandom positive whole number between a minium and maximum inclusive, parses input and shortcuts if the inputs are equal or the maximum is 0. If ether input is not parseable it will return 0.
easyRandom // returns a whole number from 1 to 6
Returns a pseudorandom whole number between 0 and 100 inclusive
easyRandom // returns a whole number from 0 to 100
Returns a psuedorandom whole number between 0 and your maximum inclusive, it parses input and shortcuts if the input is 0, it will happily explode if you pass a number that's too big. If input is not parseable it will return 0.
easyRandom // returns a whole number from 0 to 200
Returns a pseudorandom alphanumeric string of optional length, default length is 7. Returns empty string for 0 length.
easyRandom // returns a random alphanumeric string of 20 characters
Returns a pseudorandom alpha string of optional length, default length is 7. Returns empty string for 0 length.
easyRandom // returns a random alpha string of 20 characters
.getStringWithCustomCharacterSet(length (optional), characterset (optional))
Returns a string inside a custom character set of optional length, defaults to alphanumeric and length of 7. Returns empty string for 0 length.
easyRandom // returns a random string from characterset provided of 20 characters
This is functionality i need to
shamelessly steal add.
Returns a pseudorandom date.
Returns a date between two dates, accepts two date objects, returns today if minimum is larger than maximum or if either isn't a date.