1.0.0 • Published 5 years ago

wattage v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Wattage

A library for random data generation. You can choose a variety of PRNGs for the generation, and can generate in a wide variety of formats.

Supports:

  • ISAAC
  • math-random
  • seedrandom
  • Alea
  • Tyche
  • xorshift7
  • xorwow
  • xor128
  • xor4096
  • Math.random

Generation

Many of the methods are simply to aid in the generation of complex formats or formats requiring a dataset, like dates or names.

To create a new instance of the class, do something like

const Wattage = require("wattage");
const watt = new Wattage("alea", "seed"); /*
    The PRNG will default to Math.random without specifying
    'isaac', 'alea', 'math-random', 'xor128', 'tyche', 'xorwow',
    'xor4096', 'xorshift7', or 'seedrandom'. The PRNGs will be
    auto-seeded with Math.random() if no seed is provided. To
    specify Math.random, use 'default'.
*/

int(min, max)

Return an integer from min to max (inclusive).

float(min, max)

Return a float from min to max (inclusive), or from 0 to 1 if no min or max is provided.

string(length, min, max)

Return a string of length length with characters that are between the ASCII values min and max. The default for the minimum and maximum ASCII values include a-z, A-Z, 0-9, and all ASCII punctuation (that's not an accent).

base64(chunks, min, max)

Return a base64 string with chunks chunks that is the encoding of ASCII values between min and max. See above for the defaults for these two values.

bytes(bytes, min, max)

Return a Buffer with bytes bytes that is the representation of ASCII values between min and max. See above for the defaults for these two values.

name({ length, startsWith })

Return 1 of 10,000 names. You can filter the results somewhat by providing an object with length and startsWith attributes, as shown below.

watt.name({length: 5, startsWith: ['a', 'b', 'c']}) //=> "AVERY"

You can exclude either attribute to only filter by the other.

streetName()

Return 1 of 126 actual street names (I'm working on getting more).

callsign()

Return a callsign in the FCC standard format.

licensePlate()

Return a standard license plate number (for US plates).

date()

Return a date from January 1, 1970 00:00:00 to December 31, 2019 23:59:59. Accounts for the number of days in each month and leap years, and returns a Date object.

rgb()

Return a color in the form of an object with attributes r, g, and b.