File: function.md

package info (click to toggle)
node-chance 2.2.6%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,656 kB
  • sloc: javascript: 16,572; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.