From 46e43f4bde4a35785b4997b81e86cd19f046b69b Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 21 Dec 2021 16:52:28 +0100 Subject: Commit --- src/node_modules/chance/docs/usage/browser.md | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/node_modules/chance/docs/usage/browser.md (limited to 'src/node_modules/chance/docs/usage/browser.md') diff --git a/src/node_modules/chance/docs/usage/browser.md b/src/node_modules/chance/docs/usage/browser.md new file mode 100644 index 0000000..54c772c --- /dev/null +++ b/src/node_modules/chance/docs/usage/browser.md @@ -0,0 +1,58 @@ +# browser + +#### Easy + +**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. + +```html + + +``` + +The above snippet would result in either true or false being logged to your +console. Note how the instance is lowercase *chance*. Uppercase *Chance* is the +constructor which will create a new instance of **Chance**. + +#### Intermediate + +You can also ignore the global instantiation of **Chance** and create your own. +This allows you to create multiple instances if you'd like. For convenience, we +also bind **Chance** to window so it's accessible globally in the browser at +*window.Chance* or just *Chance*. + +```html + + +``` + + +#### Advanced + +If you create your own instance of **Chance**, you can provide your own seed if +you would like to be repeatable or if you'd like a more truly random seed. In +the below example, I am doing an AJAX call to hit [Random.org][random] to +retrieve a *true* random number which I use to seed Chance. + +```html + + + +``` + +[random]: http://www.random.org -- cgit