aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2016-09-25 21:43:01 -0400
committerGitHub <[email protected]>2016-09-25 21:43:01 -0400
commit2ad5b70d4134e4b68a64d32cc3c9a9322ef6af9a (patch)
treefff9711787c897cf696d8d90a30a1d1d86791f2e /lib
parent1dc26b11873a5e0479047c2ce57bfa48b8a19fce (diff)
parent7e888f758192592a969c068943823526555dc34a (diff)
downloadfaker-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.js3
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;