UNPKG

4.11 kBMarkdownView Raw
1# Chance
2
3[![Chance Logo](http://chancejs.com/logo.png)](http://chancejs.com)
4
5[![Build Status](https://travis-ci.org/victorquinn/chancejs.png)](https://travis-ci.org/victorquinn/chancejs)
6
7Chance - Random generator helper for JavaScript
8
9Homepage: [http://chancejs.com](http://chancejs.com)
10
11Many more details on [http://chancejs.com](http://chancejs.com) but this single
12library can generate random numbers, characters, strings, names, addresses,
13dice, and pretty much anything else.
14
15It includes the basic building blocks for all these items and is built on top
16of a Mersenne Twister so it can generate these things with repeatability, if
17desired.
18
19## Usage
20
21### Browser
22
23Chance 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.
24
25```html
26<script src="chance.js"></script>
27<script>
28 console.log(chance.string());
29</script>
30```
31
32[More info](http://chancejs.com#browser)
33
34### Bower
35
36It can also be used with [Bower](http://bower.io)
37
38```
39bower install chance
40```
41
42then in the HTML of your app:
43
44```html
45<!-- Load Chance -->
46<script type="text/javascript" src="app/bower_components/chance/chance.min.js"></script>
47<script>
48 // Use Chance immediately!
49 alert(chance.string());
50</script>
51```
52
53### Component
54
55It can also be used with [Component](http://component.io)
56
57```
58component install victorquinn/chancejs
59```
60
61then in the HTML of your app:
62
63```html
64<!-- Load Chance -->
65<script type="text/javascript" src="components/victorquinn-chancejs/chance.js"></script>
66<script>
67 // Use Chance immediately!
68 alert(chance.string());
69</script>
70```
71
72### Node.js
73
74And it can be used in Node.js.
75
76```js
77var Chance = require('chance'),
78 chance = new Chance();
79
80// Get a random zip code
81chance.zip();
82```
83
84### RequireJS
85
86Chance also includes an AMD define so it can be used with RequireJS.
87
88```js
89require(['Chance'], function(Chance) {
90 // Instantiate
91 var chance = new Chance();
92
93 // Then just use it:
94 var my_random_integer = chance.integer();
95});
96
97## Author
98### Victor Quinn
99[http://victorquinn.com](http://victorquinn.com)
100
101Please feel free to reach out to me if you have any questions or suggestions.
102
103### Contributors
104
105THANK YOU!
106
107```
108project : chancejs
109 repo age : 1 year, 2 months
110 active : 89 days
111 commits : 346
112 files : 21
113 authors :
114 257 Victor Quinn 74.3%
115 13 Tim Petricola 3.8%
116 11 davmillar 3.2%
117 5 Alex DiLiberto 1.4%
118 5 Matt Klaber 1.4%
119 5 Michael Cordingley 1.4%
120 4 Kevin Garnett 1.2%
121 4 Avishaan 1.2%
122 4 Abhijeet Pawar 1.2%
123 3 qjcg 0.9%
124 3 Alexandr Lozovyuk 0.9%
125 3 Nicholas Johnson 0.9%
126 2 xshyamx 0.6%
127 2 Adam Krebs 0.6%
128 2 Andreas Koeberle 0.6%
129 2 Chris Villarreal 0.6%
130 2 Iskren Chernev 0.6%
131 2 Pascal Borreli 0.6%
132 2 dhilipsiva 0.6%
133 2 path411 0.6%
134 2 shyam 0.6%
135 1 Richard Anaya 0.3%
136 1 Johannes Stein 0.3%
137 1 ddunning 0.3%
138 1 Doug Lawrence 0.3%
139 1 flrent 0.3%
140 1 leesei 0.3%
141 1 lkptrzk 0.3%
142 1 Dominic Barnes 0.3%
143 1 Ryan Tenney 0.3%
144 1 Samuel Greene 0.3%
145 1 Ng, Patrick 0.3%
146```
147
148### Contribute!
149
150Be a part of this project! You can run the test using the following.
1511. Install dependencies from package.json by running `npm install`
1522. Install dependencies for testing by running `bower install`
1533. Run the test via `npm test`
1544. Make some fun new modules!
155
156This project is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License) so feel free to hack away :)
157
158[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/victorquinn/chancejs/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
159
160Proudly written in Washington, D.C.
161
162
\No newline at end of file