diff options
| author | Matthew Bergman <[email protected]> | 2014-08-13 16:33:15 -0400 |
|---|---|---|
| committer | Matthew Bergman <[email protected]> | 2014-08-13 16:33:15 -0400 |
| commit | e0929896836b6bbdddc9740d58a73b887c304cb0 (patch) | |
| tree | 0fae12f350b2a9305a5d3a9a1bbd9f8a90da51be /lib | |
| parent | 007167b9e44b3ad8701630e22099e4f4dee7657e (diff) | |
| parent | 45160e59709716801d08dc211cc64435a789b604 (diff) | |
| download | faker-e0929896836b6bbdddc9740d58a73b887c304cb0.tar.xz faker-e0929896836b6bbdddc9740d58a73b887c304cb0.zip | |
Merge pull request #95 from avanderhoorn/random-update
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 |
