aboutsummaryrefslogtreecommitdiff
path: root/src/modules/random
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-03-07 10:09:29 +0100
committerGitHub <[email protected]>2023-03-07 09:09:29 +0000
commit9a35dc92260585683132172f10bcdec701ed661a (patch)
tree35a5711ba5a5fbc18a8f62515d1ae8b25af77023 /src/modules/random
parenta4d5203511e6ea7e26bc8c75baf91ee44387cac0 (diff)
downloadfaker-9a35dc92260585683132172f10bcdec701ed661a.tar.xz
faker-9a35dc92260585683132172f10bcdec701ed661a.zip
refactor!: remove dynamic locale switching support (#1735)
Diffstat (limited to 'src/modules/random')
-rw-r--r--src/modules/random/index.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts
index bf1c4d22..a2847bbc 100644
--- a/src/modules/random/index.ts
+++ b/src/modules/random/index.ts
@@ -1,4 +1,5 @@
import type { Faker } from '../..';
+import { FakerError } from '../../errors/faker-error';
import { deprecated } from '../../internal/deprecated';
import type { LiteralUnion } from '../../utils/types';
import type {
@@ -171,16 +172,21 @@ export class RandomModule {
}
/**
- * Returns a random locale, that is available in this faker instance.
- * You can use the returned locale with `faker.setLocale(result)`.
+ * Do NOT use. This property has been removed.
*
* @example
- * faker.random.locale() // 'el'
+ * faker.helpers.objectKey(allLocales)
+ * faker.helpers.objectValue(allFakers)
*
* @since 3.1.0
+ *
+ * @deprecated Use `faker.helpers.objectKey(allLocales/allFakers)` instead.
*/
- locale(): string {
- return this.faker.helpers.arrayElement(Object.keys(this.faker.locales));
+ private locale(): never {
+ // We cannot invoke this ourselves, because this would link to all locale data and increase the bundle size by a lot.
+ throw new FakerError(
+ 'This method has been removed. Please use `faker.helpers.objectKey(allLocales/allFakers)` instead.'
+ );
}
/**