Code Monkey home page Code Monkey logo

chancejs's Introduction

Chance

Chance Logo

Build Status

Chance - Random generator helper for JavaScript

Homepage: http://chancejs.com

Many more details on http://chancejs.com but this single library can generate random numbers, characters, strings, names, addresses, dice, and pretty much anything else.

It includes the basic building blocks for all these items and is built on top of a Mersenne Twister so it can generate these things with repeatability, if desired.

Packages

Bower

It can also be used with Bower

bower install chance

then in the HTML of your app:

<!-- Load Chance -->
<script type="text/javascript" src="components/chance/chance.min.js"></script>
<script>
    // Use Chance immediately!
    alert(chance.string());
</script>

npm

npm install chance

spm

It can also be used with spm.

spm install chance

Usage

Browser

Chance instantiates itself onto the window. This means that in the simplest case you can just include the script tag then use an instance of Chance immediately.

<script src="chance.js"></script>
<script>
    console.log(chance.string());
</script>

More info

CLI

To use Chance from the command line, install it globally with:

npm install -g chance

Then invoke any generator by name, like so:

$ chance name --prefix
Dr. Georgia Sanchez

$ chance latitude --min=12.34 --max 56.78
22.01836

Node.js

And it can be used in Node.js.

var Chance = require('chance'),
    chance = new Chance();
    
// Get a random zip code
chance.zip();

RequireJS

Chance also includes an AMD define so it can be used with RequireJS.

require(['Chance'], function(Chance) {
    // Instantiate
    var chance = new Chance();
   
    // Then just use it:
    var my_random_integer = chance.integer();
});

Author

Victor Quinn

http://victorquinn.com

Please feel free to reach out to me if you have any questions or suggestions.

Contributors

THANK YOU!

project  : chancejs
 repo age : 1 year, 6 months
 active   : 109 days
 commits  : 426
 files    : 24
 authors  :
   294	Victor Quinn        69.0%
    25	Oliver Salzburg     5.9%
    13	Tim Petricola       3.1%
    11	davmillar           2.6%
     7	Jan Tojnar          1.6%
     5	Michael Cordingley  1.2%
     5	Alex DiLiberto      1.2%
     5	Matt Klaber         1.2%
     4	Avishaan            0.9%
     4	Abhijeet Pawar      0.9%
     4	Kevin Garnett       0.9%
     4	Chris Villarreal    0.9%
     3	Nicholas Johnson    0.7%
     3	Alexandr Lozovyuk   0.7%
     3	qjcg                0.7%
     2	xshyamx             0.5%
     2	Adam Krebs          0.5%
     2	Andreas Koeberle    0.5%
     2	Iskren Chernev      0.5%
     2	Nathan MacInnes     0.5%
     2	Pascal Borreli      0.5%
     2	SeeSchloss          0.5%
     2	Stefan Penner       0.5%
     2	dhilipsiva          0.5%
     2	path411             0.5%
     2	shyam               0.5%
     1	Brian.Barnett       0.2%
     1	Johannes Stein      0.2%
     1	afc163              0.2%
     1	Doug Lawrence       0.2%
     1	ddunning            0.2%
     1	Dominic Barnes      0.2%
     1	flrent              0.2%
     1	kkroner             0.2%
     1	leesei              0.2%
     1	Richard Anaya       0.2%
     1	Ryan Tenney         0.2%
     1	Samuel Greene       0.2%
     1	lkptrzk             0.2%
     1	Ng Patrick          0.2%

Contribute!

Be a part of this project! You can run the test using the following.

  1. Install dependencies from package.json by running npm install
  2. Install dependencies for testing by running bower install
  3. Run the test via npm test
  4. Make some fun new modules!

This project is licensed under the MIT License so feel free to hack away :)

Proudly written in Washington, D.C.

chancejs's People

Contributors

abhijeetkpawar avatar afc163 avatar akre54 avatar aleksraiden avatar alexdiliberto avatar avishaan avatar christophior avatar daedalus28 avatar davmillar avatar dhilipsiva avatar eskimoblood avatar flrent avatar ichernev avatar johnsonnc avatar jtojnar avatar kevingarnett avatar leesei avatar lkptrzk avatar mcordingley avatar mklaber avatar nathanmacinnes avatar oliversalzburg avatar path411 avatar pborreli avatar qjcg avatar seeschloss avatar stefanpenner avatar timpetricola avatar victorquinn avatar xshyamx 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.