rollstack

A isomorphic javascript library for generating random data (including seeds, numbers and strings)

Usage no npm install needed!

<script type="module">
  import rollstack from 'https://cdn.skypack.dev/rollstack';
</script>

README

Rollstack 2.0.0

A isomorphic javascript library for generating random data (including seeds, numbers and strings)

License Version Bundle size XO code style Ava testing framework

Installation

Node

Install the package

npm install rollstack

Import the module into your application

const rollstack = require('rollstack') 

Browser

For usage in the browser add one of the following CDN's The global variable rollstack will then be available

<script src="https://cdn.jsdelivr.net/npm/rollstack"></script>
<!-- or -->
<script src="https://unpkg.com/rollstack"></script>

Usage

randomSeed()

Generate a random float number. this number can be used to seed other randomizer functions

let seed = rollstack.generateSeed()
console.log(seed)

randomNumber()

Generate random integer number between a specified range (inclusive)

// number between 1 and 10 (including 1 and 10)
let num = rollstack.randomNumber(1, 10)
console.log(num)

randomString()

Generate random string with specified length

let str = rollstack.randomString(10)
console.log(str)

randomString() with predefined character sets

You can optionally use a predefined set of character: options are | Set name | Characters | |----------|------------------------------------------------------------------| | alphabet | abcdefghijklmnopqrstuvwxyz | | number | 0123456789 | | hex | 0123456789abcdef | | base64 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ | | alphanum | 0123456789abcdefghijklmnopqrstuvwxyz | alphanum is the default charset

let str = rollstack.randomString(10, 'hex')
console.log(str)

randomString() with custom character set

To use a custom character set, provide an array of strings

let str = rollstack.randomString(10, ['aB├žOI23'])
console.log(str)