aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/helpers/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts
index 1b28ddfa..7f056b9f 100644
--- a/src/modules/helpers/index.ts
+++ b/src/modules/helpers/index.ts
@@ -783,7 +783,10 @@ export class Helpers {
count?: number
): T[] {
if (typeof count !== 'number') {
- count = this.faker.datatype.number({ min: 1, max: array.length });
+ count =
+ array.length === 0
+ ? 0
+ : this.faker.datatype.number({ min: 1, max: array.length });
} else if (count > array.length) {
count = array.length;
} else if (count < 0) {