Giter Club home page Giter Club logo

nonsense's Introduction

Nonsense

Generate repeatable random data in JS

Inspired by Faker.js Uses slightly modified Alea PRNG

Usage

Instantiation

To create a new Nonsense instance, do var ns = new Nonsense();. You can pass any number of arbitrary arguments to the Nonsense() constructor to be used as seed data. If you don't pass anything, it will just use the default.

Seeding

If you want to reset the seed of an instance you already have, call ns.sow() and pass in the seed data you want to use. The constructor calls sow() internally on instantiation.

Numbers

  • integer() - returns a random integer between 0 and 2^32
  • frac() - returns a random real number between 0 and 1
  • real() - returns a random real number between 0 and 2^32
  • integerInRange(min, max) - returns a random integer between min and max
  • realInRange(min, max) - returns a random real number between min and max
  • normal() - returns a random real number between -1 and 1

Utilities

  • uuid() - returns a valid v4 UUID hex string
  • pick(array) - returns a random member of array
  • weightedPick(array) - returns a random member of array, favoring the earlier entries
  • timestamp(min, max) - returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified

Language

  • word() - returns a random word of lipsum
  • words(n) - returns n random words of lipsum, 3 if not specified
  • sentence() - returns a random lipsum sentence
  • sentences(n) - returns n random lipsum sentences, 3 if not specified

Miscellaneous

  • firstName() - returns a random common first name
  • lastName() - returns a random common last name
  • name() - returns a random first and last name
  • jobTitle() - returns a random job title
  • buzzPhrase() - returns a random web 2.0 business plan...

License

Do whatever you want with this code. The consequenses of your actions are your own responsibility.

nonsense's People

Contributors

jocafa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.