aboutsummaryrefslogtreecommitdiff
path: root/src/random.ts
diff options
context:
space:
mode:
authorErica Clark <[email protected]>2022-01-19 10:45:05 -0800
committerGitHub <[email protected]>2022-01-19 19:45:05 +0100
commitec4efba989c0a997ab55152697cbefbad160f562 (patch)
tree11bd4c96b7e93845690a41f5c11ea179780514dd /src/random.ts
parentbd251ed1f08ab80b443d18d2ca62b7d2fa1f4cbe (diff)
downloadfaker-ec4efba989c0a997ab55152697cbefbad160f562.tar.xz
faker-ec4efba989c0a997ab55152697cbefbad160f562.zip
chore: add support for readonly arrays (#189)
Co-authored-by: Shinigami <[email protected]>
Diffstat (limited to 'src/random.ts')
-rw-r--r--src/random.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/random.ts b/src/random.ts
index d460b4e3..8414134a 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -72,7 +72,7 @@ export class Random {
* @method faker.random.arrayElement
* @param array
*/
- arrayElement<T = string>(array: T[] = ['a', 'b', 'c'] as unknown as T[]): T {
+ arrayElement<T = string>(array: ReadonlyArray<T> = ['a', 'b', 'c'] as unknown as ReadonlyArray<T>): T {
const r = this.faker.datatype.number({ max: array.length - 1 });
return array[r];
}
@@ -85,7 +85,7 @@ export class Random {
* @param count number of elements to pick
*/
arrayElements<T>(
- array: T[] = ['a', 'b', 'c'] as unknown as T[],
+ array: ReadonlyArray<T> = ['a', 'b', 'c'] as unknown as ReadonlyArray<T>,
count?: number
): T[] {
if (typeof count !== 'number') {