Skip to content

Latest commit

 

History

History
86 lines (66 loc) · 2.7 KB

README.md

File metadata and controls

86 lines (66 loc) · 2.7 KB

Chancer

Tools for generating different types of random behaviour in Javascript.

NPM version Node.js version support MIT licensed Code coverage Build status

Getting Started

You can use Chancer on the server side with Node.js and npm:

npm install chancer

On the client side, you can include Chancer in your page (found in build/chancer.js):

<script src="chancer.js"></script>

Usage

In Node.js you can include Chancer in your script by using require:

var chancer = require('chancer');

If you're including via a <script> tag, chancer is available as a global variable.

chancer.random()

Generates a floating-point number between 0 and 1
return: (float) Returns the floating point number

chancer.random(); // 0.32831766246818006

chancer.float( min, max )

Generates a floating-point number between min (inclusive) and max (exclusive)
min: (float) Minimum inclusive number
max: (float) Maximum exclusive number
return: (float) Returns the floating point number

chancer.float(1, 10); // 2.794354454614222

chancer.int( min, max )

Generates an integer between min (inclusive) and max (inclusive) min: (float) Minimum inclusive number
max: (float) Maximum inclusive number
return: (integer) Returns the integer number

chancer.int(1, 10); // 3

Browser Support

Tested in the following browsers

Chrome Opera Firefox Safari IE iOS Android WindowsPhone
chrome Opera firefox safari ie 3+ 2.2+ 8.1+

License

Chancer is licensed under the MIT license.
Copyright © 2015, Alex Kilgour