diff options
| author | Marak <[email protected]> | 2016-09-25 21:43:01 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-09-25 21:43:01 -0400 |
| commit | 2ad5b70d4134e4b68a64d32cc3c9a9322ef6af9a (patch) | |
| tree | fff9711787c897cf696d8d90a30a1d1d86791f2e /lib | |
| parent | 1dc26b11873a5e0479047c2ce57bfa48b8a19fce (diff) | |
| parent | 7e888f758192592a969c068943823526555dc34a (diff) | |
| download | faker-2ad5b70d4134e4b68a64d32cc3c9a9322ef6af9a.tar.xz faker-2ad5b70d4134e4b68a64d32cc3c9a9322ef6af9a.zip | |
Merge pull request #405 from HowWeRollingham/master
[fix] Don't throw in helpers.shuffle on empty array
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/helpers.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/helpers.js b/lib/helpers.js index ac3398d7..cec043bc 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -83,6 +83,9 @@ var Helpers = function (faker) { * @param {array} o */ self.shuffle = function (o) { + if (o.length === 0) { + return []; + } o = o || ["a", "b", "c"]; for (var j, x, i = o.length-1; i; j = faker.random.number(i), x = o[--i], o[i] = o[j], o[j] = x); return o; |
