mirror of
https://gitee.com/bimuziyan/ccc-obfuscated-code.git
synced 2026-06-01 16:39:06 +08:00
update
This commit is contained in:
19
node_modules/chance/docs/usage/bower.md
generated
vendored
Normal file
19
node_modules/chance/docs/usage/bower.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# bower
|
||||
|
||||
Chance can be easily installed with [Bower](https://bower.io)
|
||||
|
||||
```bash
|
||||
bower install chance
|
||||
```
|
||||
|
||||
then in the HTML of your app:
|
||||
|
||||
```html
|
||||
<!-- Load Chance -->
|
||||
<script type="text/javascript" src="bower_components/chance/chance.js"></script>
|
||||
<script>
|
||||
// Use Chance
|
||||
alert(chance.string());
|
||||
</script>
|
||||
```
|
||||
|
||||
58
node_modules/chance/docs/usage/browser.md
generated
vendored
Normal file
58
node_modules/chance/docs/usage/browser.md
generated
vendored
Normal file
@@ -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
|
||||
<script src="chance.js"></script>
|
||||
<script>
|
||||
console.log(chance.bool());
|
||||
</script>
|
||||
```
|
||||
|
||||
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
|
||||
<script src="chance.js"></script>
|
||||
<script>
|
||||
var my_chance = new Chance();
|
||||
console.log(my_chance.bool());
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
#### 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
|
||||
<script src="http://chancejs.com/chance.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
|
||||
<script>
|
||||
var mySeed;
|
||||
$.get("https://www.random.org/integers/", {num: "1", col: "1", min: "1", max: "1000000000", base: "10", format: "plain", rnd: "new"}, function(randNum) {
|
||||
mySeed = randNum;
|
||||
|
||||
// Instantiate Chance with this truly random number as the seed
|
||||
var my_seeded_chance = new Chance(mySeed);
|
||||
console.log(my_seeded_chance.natural());
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
[random]: http://www.random.org
|
||||
19
node_modules/chance/docs/usage/cli.md
generated
vendored
Normal file
19
node_modules/chance/docs/usage/cli.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# cli
|
||||
|
||||
To use Chance from the command line, install `chance-cli` globally with:
|
||||
|
||||
```bash
|
||||
npm install -g chance-cli
|
||||
```
|
||||
|
||||
Then invoke any generator by name followed by options, like so:
|
||||
|
||||
```bash
|
||||
$ chance name --prefix true
|
||||
Dr. Georgia Sanchez
|
||||
|
||||
$ chance latitude --min 12.34 --max 56.78
|
||||
22.01836
|
||||
```
|
||||
|
||||
More details in the [chance-cli README](https://github.com/chancejs/chance-cli)
|
||||
22
node_modules/chance/docs/usage/function.md
generated
vendored
Normal file
22
node_modules/chance/docs/usage/function.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# function
|
||||
|
||||
Instead of providing a seed, which will be used to seed our [Mersenne Twister](https://en.wikipedia.org/wiki/Mersenne_twister),
|
||||
you can also specify an arbitrary function to generate random numbers which the
|
||||
rest of the library will utilize when generating everything else.
|
||||
|
||||
A rather simple example, simply using Math.random() instead of our Mersenne Twister
|
||||
|
||||
```js
|
||||
// Use Math.random() instead of our Mersenne Twister
|
||||
var chance = new Chance(Math.random);
|
||||
|
||||
chance.address()
|
||||
=> '131 Asmun Pike'
|
||||
chance.address()
|
||||
=> '261 Pawnaf Highway'
|
||||
```
|
||||
|
||||
Chance will appear to work just the same, but have a different underlying random
|
||||
generator.
|
||||
|
||||
This function should return any number between 0 and 1.
|
||||
31
node_modules/chance/docs/usage/node.md
generated
vendored
Normal file
31
node_modules/chance/docs/usage/node.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# node
|
||||
|
||||
It can also be used in [Node.js](http://nodejs.org)
|
||||
|
||||
```bash
|
||||
npm install chance
|
||||
```
|
||||
|
||||
then in your app
|
||||
|
||||
```js
|
||||
// Load Chance
|
||||
var Chance = require('chance');
|
||||
|
||||
// Instantiate Chance so it can be used
|
||||
var chance = new Chance();
|
||||
|
||||
// Use Chance here.
|
||||
var my_random_string = chance.string();
|
||||
```
|
||||
|
||||
As of version 0.5.5, the following is also offered as a convenience for getting
|
||||
an instance of Chance
|
||||
|
||||
```js
|
||||
// Load and instantiate Chance
|
||||
var chance = require('chance').Chance();
|
||||
|
||||
// Use Chance here.
|
||||
var my_random_string = chance.string();
|
||||
```
|
||||
13
node_modules/chance/docs/usage/requirejs.md
generated
vendored
Normal file
13
node_modules/chance/docs/usage/requirejs.md
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# requirejs
|
||||
|
||||
Load Chance with <a href="http://requirejs.org">RequireJS</a>
|
||||
|
||||
```js
|
||||
require(['Chance'], function(Chance) {
|
||||
// Instantiate
|
||||
var chance = new Chance();
|
||||
|
||||
// Then use it:
|
||||
var my_random_integer = chance.integer();
|
||||
});
|
||||
```
|
||||
49
node_modules/chance/docs/usage/seed.md
generated
vendored
Normal file
49
node_modules/chance/docs/usage/seed.md
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# seed
|
||||
|
||||
You can also instantiate your own instance of Chance with a known seed. This is
|
||||
useful for creating repeatable results.
|
||||
|
||||
```js
|
||||
var chance1 = new Chance(12345);
|
||||
var chance2 = new Chance(12345);
|
||||
|
||||
// These yield the same values, in sequence
|
||||
console.log(chance1.random());
|
||||
console.log(chance2.random());
|
||||
```
|
||||
|
||||
Since both copies of Chance had the same seed, they will both generate the same
|
||||
random number sequence each time they're called.
|
||||
|
||||
This allows for repeatability, if desired.
|
||||
|
||||
This is possible because **Chance** is built atop a [Mersenne Twister][mersenne],
|
||||
a pseudo-random number generator which produces repeatable results given the same seed.
|
||||
|
||||
Optionally provide the seed as a string.
|
||||
|
||||
```js
|
||||
var chance1 = new Chance("foo");
|
||||
var chance2 = new Chance("bar");
|
||||
|
||||
// These will be different
|
||||
console.log(chance1.random());
|
||||
console.log(chance2.random());
|
||||
```
|
||||
|
||||
Optionally provide multiple arguments as the seed.
|
||||
|
||||
```js
|
||||
var chance1 = new Chance("hold", "me", "closer");
|
||||
var chance2 = new Chance("tony", "danza");
|
||||
var chance3 = new Chance("hold", "me", "closer");
|
||||
|
||||
// These will be different
|
||||
console.log(chance1.random());
|
||||
console.log(chance2.random());
|
||||
|
||||
// This will be the same as the value from chance1 above
|
||||
console.log(chance3.random());
|
||||
```
|
||||
|
||||
[mersenne]: http://en.wikipedia.org/wiki/Mersenne_twister
|
||||
Reference in New Issue
Block a user