diff options
| author | Anthony van der Hoorn <[email protected]> | 2014-07-23 01:02:03 +0100 |
|---|---|---|
| committer | Anthony van der Hoorn <[email protected]> | 2014-07-23 01:02:03 +0100 |
| commit | 45160e59709716801d08dc211cc64435a789b604 (patch) | |
| tree | 431124b56f0d1b506174e134526086911a728e6b /lib | |
| parent | 6bed149da3df03edbe9a87145c8471d965d1bc3b (diff) | |
| download | faker-45160e59709716801d08dc211cc64435a789b604.tar.xz faker-45160e59709716801d08dc211cc64435a789b604.zip | |
Updates to switch changes over to using 2 args to support min/max
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/random.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/random.js b/lib/random.js index 63347278..6205dc09 100644 --- a/lib/random.js +++ b/lib/random.js @@ -1,13 +1,12 @@ var definitions = require('./definitions'); var random = { // returns a single random number based on a max number or range - number: function (range) { - if(Array.isArray(range)) { - var min = range[0]; - var max = range[1]; - return Math.floor((Math.random() * max) + min); + number: function (min, max) { + if (max === undefined) { + max = min; + min = 0; } - return Math.floor(Math.random() * range); + return Math.floor((Math.random() * max) + min); }, // takes an array and returns the array randomly sorted |
