diff options
| author | ST-DDT <[email protected]> | 2024-06-21 11:49:51 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-21 09:49:51 +0000 |
| commit | d31c635e6efc4013ea44a6676f832091c1763050 (patch) | |
| tree | b648d4ab8b9d8e16f18cfd7b5c01c8fd89d90ffd /docs | |
| parent | d6924f7fbb9403d106022f58a1bda3b159e88ae6 (diff) | |
| download | faker-d31c635e6efc4013ea44a6676f832091c1763050.tar.xz faker-d31c635e6efc4013ea44a6676f832091c1763050.zip | |
chore: remove arrayElement(s) js only error (#2958)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/guide/upgrading.md | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/guide/upgrading.md b/docs/guide/upgrading.md index 9797a48c..beccc457 100644 --- a/docs/guide/upgrading.md +++ b/docs/guide/upgrading.md @@ -349,6 +349,24 @@ const city = enforcer.enforce(faker.location.city, { `enforce-unique` does not directly support the `store` option previously available in `faker.helpers.unique`. If you were previously using this parameter, check the [documentation](https://www.npmjs.com/package/enforce-unique). If you need to reset the store, you can call the `reset()` method on the `UniqueEnforcer` instance. ::: +#### `faker.helpers.arrayElement` and `faker.helpers.arrayElements` + +The following only affects usage in Javascript, as in Typescript this usage would already throw a compile-time error. + +Previously, the `arrayElement` and `arrayElements` methods would throw a dedicated error, when called without arguments. + +```ts +faker.helpers.arrayElement(undefined); // FakerError: Calling `faker.helpers.arrayElement()` without arguments is no longer supported. +``` + +Now, it throws a JS native error: + +```ts +faker.helpers.arrayElement(undefined); // TypeError: Cannot read properties of undefined (reading 'length') +``` + +Calling the methods with an empty array instead still behaves as before. + ### Image Module Removed deprecated image methods |
