diff --git a/.github/.codecov.yml b/.github/.codecov.yml
index d782656df33..1cd3212beed 100644
--- a/.github/.codecov.yml
+++ b/.github/.codecov.yml
@@ -11,3 +11,7 @@ coverage:
default:
target: 95%
threshold: 2%
+ patch:
+ default:
+ target: 40%
+ threshold: 1%
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 3cb46b54643..26aa1f94a70 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,20 +1,20 @@
# These owners will be the default owners for everything in the repo.
-# Unless a later match takes precedence, @faker-js/maintainers will
+# Unless a later match takes precedence, @faker-js/maintainers will
# be requested for review when someone opens a pull request.
-* @faker-js/maintainers
+* @faker-js/maintainers
# ================================================
# Docs owners ...
# ================================================
-/docs/ @faker-js/maintainers-docs
-netlify.toml @faker-js/maintainers-docs
-README.md @faker-js/maintainers-docs @faker-js/maintainers
-CONTRIBUTING.md @faker-js/maintainers-docs
+/docs/ @faker-js/maintainers-docs @faker-js/maintainers
+netlify.toml @faker-js/maintainers-docs @faker-js/maintainers
+README.md @faker-js/maintainers-docs @faker-js/maintainers
+CONTRIBUTING.md @faker-js/maintainers-docs @faker-js/maintainers
# ================================================
# CODEOWNERS owners ...
# ================================================
-/.github/CODEOWNERS @faker-js/maintainers
+/.github/CODEOWNERS @faker-js/maintainers
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 2f0dffd8622..4aef7e5ed88 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -1,6 +1,6 @@
name: "\U0001F41E Bug report"
description: Report an issue
-labels: [pending triage] # This will automatically assign the 'pending triage' label
+labels: ['s: pending triage'] # This will automatically assign the 's: pending triage' label
body:
- type: markdown
attributes:
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index 3619e088c94..1b06f6594a6 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -1,6 +1,6 @@
name: "\U0001F680 New feature proposal"
description: Propose a new feature
-labels: ['pending triage'] # This will automatically assign the 'pending triage' label
+labels: ['s: pending triage'] # This will automatically assign the 's: pending triage' label
body:
- type: markdown
attributes:
diff --git a/.github/renovate.json5 b/.github/renovate.json5
index 505c3cd8dc8..8791aa6dbc0 100644
--- a/.github/renovate.json5
+++ b/.github/renovate.json5
@@ -1,7 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", "schedule:daily", "group:allNonMajor"],
- "labels": ["dependencies"],
+ "labels": ["c: dependencies"],
"reviewersFromCodeOwners": true,
"rangeStrategy": "bump",
"packageRules": [
@@ -51,7 +51,7 @@
}
],
"vulnerabilityAlerts": {
- "labels": ["security"],
+ "labels": ["c: security"],
"assignees": ["team:maintainers"]
}
}
diff --git a/.github/workflows/issue-labeling.yml b/.github/workflows/issue-labeling.yml
deleted file mode 100644
index ea66bbd2799..00000000000
--- a/.github/workflows/issue-labeling.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: Issue Labeling
-
-on:
- issues:
- types: [labeled]
-
-jobs:
- reply-labeled:
- runs-on: ubuntu-latest
- steps:
- - name: contribution welcome
- # If the issue is labeled with 'help wanted', a comment will be posted
- if: github.event.label.name == 'help wanted'
- uses: actions-cool/issues-helper@v3
- with:
- actions: 'welcome, remove-labels'
- token: ${{ secrets.GITHUB_TOKEN }}
- issue-number: ${{ github.event.issue.number }}
- body: |
- Hello @${{ github.event.issue.user.login }}. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
- labels: 'pending triage'
-
- - name: remove pending
- # If the issue is given either the 'enhancement' or 'bug' label, the 'pending triage' label will be removed
- # Issues without the label 'pending triage' are filtered with the third part of the condition, since the label does not have to be removed
- if: github.event.label.name == 'enhancement' || github.event.label.name == 'bug' || (contains(github.event.label.name, 'pending triage') == false)
- uses: actions-cool/issues-helper@v3
- with:
- actions: 'remove-labels'
- token: ${{ secrets.GITHUB_TOKEN }}
- issue-number: ${{ github.event.issue.number }}
- labels: 'pending triage'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5614cbbdbf..ce48536fc27 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,81 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+## [6.1.2](https://github.com/faker-js/faker/compare/v6.1.1...v6.1.2) (2022-04-04)
+
+
+### Features
+
+* FakerError ([#718](https://github.com/faker-js/faker/issues/718)) ([c3be3b1](https://github.com/faker-js/faker/commit/c3be3b1945248ed422342b046ad765d252bbac05))
+
+
+### Bug Fixes
+
+* datatype.number when min = max + precision, throw when max > min ([#664](https://github.com/faker-js/faker/issues/664)) ([0304120](https://github.com/faker-js/faker/commit/03041201c21ad599bbe1874c375f4f41b94961ba))
+* deterministic results for address.nearbyGPSCoordinate ([#737](https://github.com/faker-js/faker/issues/737)) ([bc7bd57](https://github.com/faker-js/faker/commit/bc7bd571d8d6c70b046a3bda23c61c527ddb1d4a))
+* random word fails on undefined ([#771](https://github.com/faker-js/faker/issues/771)) ([fb1b87e](https://github.com/faker-js/faker/commit/fb1b87e2249798c6257cb5383f73a15022f438f0))
+* remove doubled extension in system.filePath ([#300](https://github.com/faker-js/faker/issues/300)) ([2532eb9](https://github.com/faker-js/faker/commit/2532eb9f5a6f73bbc1786ec91952f838d98fd72a))
+
+## [6.1.1](https://github.com/faker-js/faker/compare/v6.1.0...v6.1.1) (2022-03-28)
+
+### Bug Fixes
+
+* forgot to run `pnpm run build`
+
+## [6.1.0](https://github.com/faker-js/faker/compare/v6.0.0-alpha.6...v6.1.0) (2022-03-28)
+
+⚠**WARNING**: This build is broken due to missing build files. Please don't use this version!
+
+### Features
+
+* **types:** generate all locales index files with non-any types ([#494](https://github.com/faker-js/faker/issues/494)) ([b611ca1](https://github.com/faker-js/faker/commit/b611ca1c6f7d756f224a1a7b641e36b531d169be))
+* **types:** provide strong typing for locales 2 ([#398](https://github.com/faker-js/faker/issues/398)) ([419e9e2](https://github.com/faker-js/faker/commit/419e9e20a570b44909faf24c9019bf7f232ee7a9))
+
+
+### Bug Fixes
+
+* accept dates as params for Date methods ([#200](https://github.com/faker-js/faker/issues/200)) ([91a1aab](https://github.com/faker-js/faker/commit/91a1aaba954b7d172c3dd3346567078644b74189))
+* alphaNumeric all chars banned ([#550](https://github.com/faker-js/faker/issues/550)) ([c51fb15](https://github.com/faker-js/faker/commit/c51fb1570669284e14915916636de97b7f644e17))
+* corrected the Costa Rican IBAN format ([#646](https://github.com/faker-js/faker/issues/646)) ([3f3de78](https://github.com/faker-js/faker/commit/3f3de78c83ae919fd44531ac7ae9caed885800d4))
+* correcting the readme file ([#529](https://github.com/faker-js/faker/issues/529)) ([6c9dcdd](https://github.com/faker-js/faker/commit/6c9dcdd03050ef70554fc2bb6ccc0c883fd1edc9))
+* datatype.datetime should use static boundaries ([#343](https://github.com/faker-js/faker/issues/343)) ([7141cd7](https://github.com/faker-js/faker/commit/7141cd7d8a2fd505d3338d13ca29fd1ab7a5dc80))
+* enable algolia search ([#641](https://github.com/faker-js/faker/issues/641)) ([a759c87](https://github.com/faker-js/faker/commit/a759c8707c2e3758e64e1c174c2de7aad51cd64b))
+* fake behavior with special replacement patterns ([#688](https://github.com/faker-js/faker/issues/688)) ([8d1aefb](https://github.com/faker-js/faker/commit/8d1aefbda070265909cedb07af564ea143be74a7))
+* fake is unable to return empty strings ([#347](https://github.com/faker-js/faker/issues/347)) ([301a6d2](https://github.com/faker-js/faker/commit/301a6d2024816bf40f1091ccffe6bb81cb7ba7b0))
+* **finance:** update iso-3166-1 country codes for IBAN/BIC ([#168](https://github.com/faker-js/faker/issues/168)) ([6050d7a](https://github.com/faker-js/faker/commit/6050d7acbb991568cbdac7b0c16a088aef200abc))
+* fix bicycle_types files being named incorrectly ([#477](https://github.com/faker-js/faker/issues/477)) ([7a2a522](https://github.com/faker-js/faker/commit/7a2a522c181dc696f6e9b4767ca18d39bad4476d))
+* fix time.recent method signature ([#586](https://github.com/faker-js/faker/issues/586)) ([60d3cc5](https://github.com/faker-js/faker/commit/60d3cc519cd2cab061a23fbe09164d8b59e177ff))
+* fix unique method types ([#457](https://github.com/faker-js/faker/issues/457)) ([14df7d3](https://github.com/faker-js/faker/commit/14df7d3f70b54c4a153f5dcf111ef90575bbbe9e))
+* force passed locales into faker constructor ([#580](https://github.com/faker-js/faker/issues/580)) ([5ed963f](https://github.com/faker-js/faker/commit/5ed963f1e4928eb2df36f230faf7f9d63b51bef1))
+* handle missing or broken locales main index files ([#478](https://github.com/faker-js/faker/issues/478)) ([ff97431](https://github.com/faker-js/faker/commit/ff974319a63acbcbbb96cf1a67a48616de9fd9da))
+* mersenne rand invalid input argument ([#577](https://github.com/faker-js/faker/issues/577)) ([486c76e](https://github.com/faker-js/faker/commit/486c76e34f22cf1fd66fa2c99e605d52c7077760))
+* move el credit card information to the expected location ([#484](https://github.com/faker-js/faker/issues/484)) ([dcbd18e](https://github.com/faker-js/faker/commit/dcbd18e13ab53e837de17cec7b3f8e51ba479d0e))
+* name module gender ([#644](https://github.com/faker-js/faker/issues/644)) ([7675abe](https://github.com/faker-js/faker/commit/7675abe5a62c8d44ecfd4a6f50bfb5fa50f40efa))
+* normalize provider in finance.creditCardNumber ([#662](https://github.com/faker-js/faker/issues/662)) ([9ce1551](https://github.com/faker-js/faker/commit/9ce1551ab7c9cafc97e3d051f0632591e34eb3ce))
+* only return word with desirable alpha characters ([#654](https://github.com/faker-js/faker/issues/654)) ([b7b2e4f](https://github.com/faker-js/faker/commit/b7b2e4f8dbd40b6bb2678fb60ee95e198838d08a))
+* remove invalid aliases ([#488](https://github.com/faker-js/faker/issues/488)) ([58fbfe3](https://github.com/faker-js/faker/commit/58fbfe3835b0f27949e7eb262d246eb9d84bb870))
+* remove unreachable code finance ([#508](https://github.com/faker-js/faker/issues/508)) ([1bc622a](https://github.com/faker-js/faker/commit/1bc622a9499bf236052809610ecabe80f87de482))
+* replaced placeimg.com on loremflickr.com ([#692](https://github.com/faker-js/faker/issues/692)) ([2a49e82](https://github.com/faker-js/faker/commit/2a49e8215a81ef284a2955f7f9a51d6f2bd76f5f))
+* solve various todos ([#649](https://github.com/faker-js/faker/issues/649)) ([d0a473f](https://github.com/faker-js/faker/commit/d0a473f7ca6b525391ca8ab17e029335c66ed99e))
+* test random.alphaNumeric ([#517](https://github.com/faker-js/faker/issues/517)) ([41ec6f0](https://github.com/faker-js/faker/commit/41ec6f08784afc2a674568328a0ea2bfb033a411))
+* use require/import export map in package.json ([#697](https://github.com/faker-js/faker/issues/697)) ([0f74908](https://github.com/faker-js/faker/commit/0f74908a5ac16d4a9b73d747a275a9399a131757))
+* Vehicle vin is always 17 characters long ([#320](https://github.com/faker-js/faker/issues/320)) ([d2fc1e6](https://github.com/faker-js/faker/commit/d2fc1e6b5ba55242d16b9b8a1e9f42c7b24957b0))
+
+## [6.0.0](https://github.com/faker-js/faker/compare/v6.0.0-beta.0...v6.0.0) (2022-03-15)
+
+
+### Bug Fixes
+
+* fix some lint warnings ([#613](https://github.com/faker-js/faker/issues/613)) ([5cb74b1b](https://github.com/faker-js/faker/commit/5cb74b1bf31f44311b4ee54ea320b81f68879f07))
+* **docs:** add image_providers jsdocs ([#612](https://github.com/faker-js/faker/issues/612)) ([09487b6b](https://github.com/faker-js/faker/commit/09487b6b3a6e6cc3de0303851b9913ecdf1390dc))
+* **docs:** improve visualization for complex types ([#608](https://github.com/faker-js/faker/issues/608)) ([f038937c](https://github.com/faker-js/faker/commit/f038937c973a0ad4b0014c5aaa56a0323c94fff4))
+* configure eqeqeq lint rule ([#595](https://github.com/faker-js/faker/issues/595)) ([5cd3daef](https://github.com/faker-js/faker/commit/5cd3daef2b586b7f7c89b82259831ca4810d77d5))
+* fix eslint error ([#597](https://github.com/faker-js/faker/issues/597)) ([4f7447c3](https://github.com/faker-js/faker/commit/4f7447c3e38da71d261da254dd631b84fb4c22c4))
+* **docs:** comment out algolia until search is available ([#599](https://github.com/faker-js/faker/issues/599)) ([bcc97d69](https://github.com/faker-js/faker/commit/bcc97d69ba434b436d4b173dfba8122a417e8345))
+* **docs:** add test for api docs generation ([#574](https://github.com/faker-js/faker/issues/574)) ([c99160f0](https://github.com/faker-js/faker/commit/c99160f0ab059729af29d7ee08bd97c38d323b2a))
+* **docs:** display correct signature ([#596](https://github.com/faker-js/faker/issues/596)) ([c115056e](https://github.com/faker-js/faker/commit/c115056e04d1e42f97c8d77daed3d9056c375953))
+* **docs:** show union options parameters ([#602](https://github.com/faker-js/faker/issues/602)) ([5595b9fc](https://github.com/faker-js/faker/commit/5595b9fc7bf700cb0ca3d0792a3a879110ba43c5))
+
## [6.0.0-beta.0](https://github.com/faker-js/faker/compare/v6.0.0-alpha.6...v6.0.0-beta.0) (2022-03-07)
diff --git a/LICENSE b/LICENSE
index 6901562fcb1..0ebeaf84e27 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
Faker - Copyright (c) 2022
-This software consists of voluntary contributions made by many individuals.
+This software consists of voluntary contributions made by many individuals.
For exact contribution history, see the revision history
available at https://github.com/faker-js/faker
@@ -23,7 +23,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-===
+===
From: https://github.com/faker-js/faker/commit/a9f98046c7d5eeaabe12fc587024c06d683800b8
To: https://github.com/faker-js/faker/commit/29234378807c4141588861f69421bf20b5ac635e
@@ -58,4 +58,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index d6341b9bd0c..1750d77eede 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ pnpm install @faker-js/faker -D
```
@@ -54,9 +54,10 @@ pnpm install @faker-js/faker -D
```js
const { faker } = require('@faker-js/faker');
+
const randomName = faker.name.findName(); // Rowan Nikolaus
const randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
-const randomCard = faker.helpers.createCard(); // random contact card containing many properties
+const randomPhoneNumber = faker.phone.phoneNumber(); // (279) 329-8663 x30233
```
### CDN/Deno
@@ -66,9 +67,20 @@ import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';
const randomName = faker.name.findName(); // Willie Bahringer
const randomEmail = faker.internet.email(); // Tomasa_Ferry14@hotmail.com
-const randomCard = faker.helpers.createCard(); // random contact card containing many properties
+const randomPhoneNumber = faker.phone.phoneNumber(); // 938-672-1359 x418
```
+#### Alternative CDN links
+
+**esm:**
+
+- https://esm.sh/@faker-js/faker
+- https://cdn.jsdelivr.net/npm/@faker-js/faker/+esm
+
+**cjs:**
+
+- https://cdn.jsdelivr.net/npm/@faker-js/faker
+
### TypeScript Support
Since version `v6+` there is native TypeScript support.
@@ -84,6 +96,12 @@ In order to have faker working properly, you need to check if these `compilerOpt
}
```
+And then simply import it like everything else:
+
+```ts
+import { faker } from '@faker-js/faker';
+```
+
If you want for whatever reason the versions prior to `v6`,
you can use `@types/faker` and rebind the declarations to the `@faker-js/faker` package with a `faker.d.ts` file in your e.g. src folder.
@@ -97,7 +115,7 @@ declare module '@faker-js/faker' {
## API
-An in-depth overview of the API methods is available in the documentation. The API covers the following modules:
+An in-depth overview of the API methods is available in the [documentation](https://fakerjs.dev/guide/). The API covers the following modules:
| Module | Example | Output |
| -------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -106,7 +124,7 @@ An in-depth overview of the API methods is available in the documentation. The A
| Commerce | `faker.commerce.product()` | Polo t-shirt |
| Company | `faker.company.companyName()` | Zboncak and Sons |
| Database | `faker.database.engine()` | MyISAM |
-| Datatype | `faker.datatype.uuid()` | 1oijf8-3iuhiu-21jddj-1092jf |
+| Datatype | `faker.datatype.uuid()` | 7b16dd12-935e-4acc-8381-b1e457bf0176 |
| Date | `faker.date.past()` | Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time) |
| Finance | `faker.finance.amount()` | ¥23400 (After setting locale) |
| Git | `faker.git.commitMessage()` | feat: add products list page |
@@ -122,335 +140,9 @@ An in-depth overview of the API methods is available in the documentation. The A
| System | `faker.system.directoryPath()` | C:\Documents\Newsletters\ |
| Vehicle | `faker.vehicle.vehicle()` | 2011 Dodge Caravan |
-### API Methods
-
-Faker provides many useful utility functions.
-
-- faker.address
-
- | API | Description |
- | ------------------- | ------------------------------- |
- | zipCode | Get fake zip code |
- | zipCodeByState | Get fake zip code by state |
- | city | Get fake city |
- | cityPrefix | Get fake city prefix |
- | citySuffix | Get fake city suffix |
- | cityName | Get fake city name |
- | streetName | Get fake street name |
- | streetAddress | Get fake street address |
- | streetSuffix | Get fake street suffix |
- | streetPrefix | Get fake street prefix |
- | secondaryAddress | Get fake secondary address |
- | county | Get fake county |
- | country | Get fake country |
- | countryCode | Get fake country code |
- | state | Get fake state |
- | stateAbbr | Get fake state abbreviation |
- | latitude | Get fake latitude |
- | longitude | Get fake longitude |
- | direction | Get fake direction |
- | cardinalDirection | Get fake cardinal direction |
- | ordinalDirection | Get fake ordinal direction |
- | nearbyGPSCoordinate | Get fake near by gps coordinate |
- | timeZone | Get fake timezone |
-
-- faker.animal
-
- | API | Description |
- | ---------- | ------------------------ |
- | dog | Get fake dog type |
- | cat | Get fake cat type |
- | snake | Get fake snake type |
- | bear | Get fake bear type |
- | lion | Get fake lion type |
- | cetacean | Get fake cetacean type |
- | horse | Get fake horse type |
- | bird | Get fake bird type |
- | cow | Get fake cow type |
- | fish | Get fake fish type |
- | crocodilia | Get fake crocodilia type |
- | insect | Get fake insect type |
- | rabbit | Get fake rabbit type |
-
-- faker.commerce
-
- | API | Description |
- | ------------------ | ------------------------------ |
- | color | Get fake color name |
- | department | Get fake department name |
- | productName | Get fake product name |
- | price | Get fake price count |
- | productAdjective | Get fake product adjective |
- | productMaterial | Get fake product material data |
- | product | Get fake product name |
- | productDescription | Get fake product description |
-
-- faker.company
-
- | API | Description |
- | --------------------- | ------------------------------------ |
- | suffixes | Get fake company suffixes |
- | companyName | Get fake company name |
- | companySuffix | Get fake company suffix |
- | bs | Get fake company business services |
- | catchPhraseAdjective | Get fake product adjective |
- | catchPhraseDescriptor | Get fake product material data |
- | catchPhraseNoun | Get fake product name |
- | bsAdjective | Get fake business services adjective |
- | bsBuzz | Get fake business services buzz |
- | bsNoun | Get fake business services noun |
-
-- faker.database
-
- | API | Description |
- | --------- | --------------------------------- |
- | column | Get fake database column name |
- | type | Get fake database column datatype |
- | collation | Get fake database collation |
- | engine | Get fake database engine |
-
-- faker.datatype
-
- | API | Description |
- | ----------- | ---------------------------------- |
- | number | Generates a random number |
- | float | Generates a random floating number |
- | datetime | Generates a random datetime |
- | string | Generates a random string |
- | uuid | Generates a valid uuid |
- | boolean | Generates a boolean |
- | hexaDecimal | Generates a hexadecimal |
- | json | Generates a valid json object |
- | array | Generates an array |
-
-- faker.date
-
- | API | Description |
- | -------- | -------------------------------------------------------------------------------------- |
- | past | Get a date `N` years into the past |
- | future | Get a date `N` years into the future |
- | between | Get a random date between the dates given |
- | betweens | Get an array of 3 dates ( by default ) of sorted randoms dates between the dates given |
- | recent | Get a date `N` days from the recent past |
- | soon | Get a date `N` days into the future |
- | month | Generates a random value of date month |
- | weekday | Generates a random value of date weekday |
-
-- faker.fake
-
-- faker.finance
-
- | API | Description |
- | ---------------------- | ------------------------------------------------- |
- | account | Generates a random finance account |
- | accountName | Generates a random finance account name |
- | routingNumber | Generates a random finance routing number |
- | mask | Generates a random finance mask template |
- | amount | Generates a random amount of transaction |
- | transactionType | Generates a random transaction type |
- | currencyCode | Generates a random currency code |
- | currencyName | Generates a random currency name |
- | currencySymbol | Generates a random currency symbol |
- | bitcoinAddress | Generates a random bitcoin address |
- | litecoinAddress | Generates a random litecoin address |
- | creditCardNumber | Generates a random credit card number |
- | creditCardCVV | Generates a random credit card CVV |
- | ethereumAddress | Generates a random ethereum address (ETH address) |
- | iban | Generates a random IBAN |
- | bic | Generates a random BIC |
- | transactionDescription | Generates a random transaction description |
-
-- faker.git
-
- | API | Description |
- | ------------- | ---------------------------------------------------------------- |
- | branch | Generates a random branch with hacker noun and verb |
- | commitEntry | Generates a random commit entry with git commit message and sha |
- | commitMessage | Generates a random commit message with hacker noun, adj and verb |
- | commitSha | Generates a random commit SHA |
- | shortSha | Generates a random short SHA |
-
-- faker.hacker
-
- | API | Description |
- | ------------ | -------------------------------------- |
- | abbreviation | Generates a random hacker abbreviation |
- | adjective | Generates a random hacker adjective |
- | noun | Generates a random hacker noun |
- | verb | Generates a random hacker verb |
- | ingverb | Generates a random hacker ingverb |
- | phrase | Generates a random hacker phrase |
-
-- faker.helpers
-
- | API | Description |
- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
- | randomize | Get a random element from an array |
- | slugify | Removes unwanted characters from URI string |
- | replaceSymbolWithNumber | Parses string for a symbol and replace it with a random number from 1-10 |
- | replaceSymbols | Parses string for symbols (numbers or letters) and replaces them appropriately (# will be replaced with number, ? with letter and \* will be replaced with number or letter) |
- | replaceCreditCardSymbols | Replace symbols in a credit card schema including Luhn checksum |
- | repeatString | String repeat helper, alternative to String.prototype.repeat |
- | shuffle | Takes an array and randomizes it in place then returns it using the modern version of the Fisher-Yates algorithm |
- | mustache | Generates a string with mustache {{ }} |
- | createCard | Generates a human card |
- | contextualCard | Generates a human contextual card |
- | userCard | Generates a website user card |
- | createTransaction | Generates a transaction |
-
-- faker.image
-
- | API | Description |
- | ----------- | ---------------------------------------------- |
- | image | Generates a random image |
- | avatar | Generates a random avatar |
- | imageUrl | Generates a random image url |
- | abstract | Generates a random abstract image |
- | animals | Generates a random animals image |
- | business | Generates a random business image |
- | cats | Generates a random cats image |
- | city | Generates a random city image |
- | food | Generates a random food image |
- | nightlife | Generates a random nightlife image |
- | fashion | Generates a random fashion image |
- | people | Generates a random people image |
- | nature | Generates a random nature image |
- | sports | Generates a random sports image |
- | technics | Generates a random technics image |
- | transport | Generates a random transport image |
- | dataUri | Generates a random data uri |
- | lorempixel | Generates a random image url from lorempixel |
- | unsplash | Generates a random image url from unsplash |
- | lorempicsum | Generates a random image url from lorem picsum |
-
-- faker.internet
-
- | API | Description |
- | ------------ | ---------------------------------------------------- |
- | avatar | Generates a random avatar |
- | email | Generates a random email |
- | exampleEmail | Generates a random example email |
- | userName | Generates a random user name |
- | protocol | Generates a random internet protocol (http or https) |
- | httpMethod | Generates a random http method |
- | url | Generates a random url |
- | domainName | Generates a random domain name |
- | domainSuffix | Generates a random domain suffix |
- | domainWord | Generates a random domain word |
- | ip | Generates a random ip |
- | ipv6 | Generates a random ipv6 |
- | port | Generates a random port number |
- | userAgent | Generates a random user agent |
- | color | Generates a random hexadecimal color |
- | mac | Generates a random mac address |
- | password | Generates a random password |
-
-- faker.lorem
-
- | API | Description |
- | ---------- | ----------------------------------- |
- | word | Generates a random lorem word |
- | words | Generates a random lorem words |
- | sentence | Generates a random lorem sentence |
- | slug | Generates a random lorem slug |
- | sentences | Generates a random lorem sentences |
- | paragraph | Generates a random lorem paragraph |
- | paragraphs | Generates a random lorem paragraphs |
- | text | Generates a random lorem text |
- | lines | Generates a random lorem lines |
-
-- faker.mersenne
-
- | API | Description |
- | ---------- | ---------------------------------------------- |
- | rand | Generates a random mersenne rand |
- | seed | Generates a random mersenne seed |
- | seed_array | Generates a random datetime seed init by array |
-
-- faker.music
-
- | API | Description |
- | ----- | ------------------------------ |
- | genre | Generates a random music genre |
-
-- faker.name
-
- | API | Description |
- | ------------- | ------------------------------------------------------------------------------------- |
- | firstName | Generates a random human first name |
- | lastName | Generates a random human last name |
- | middleName | Generates a random human middle name |
- | findName | Generates a random human first name and last name |
- | jobTitle | Generates a random human job title, combination of jobDescriptor, jobArea and jobType |
- | gender | Generates a random gender |
- | prefix | Generates a random locale with gender specific name prefix |
- | suffix | Generates a random locale with gender specific name suffix |
- | title | Generates a random human title |
- | jobDescriptor | Generates a random human job descriptor |
- | jobArea | Generates a random human job area |
- | jobType | Generates a random human job type |
-
-- faker.phone
-
- | API | Description |
- | ----------------- | ------------------------------------------------------------------- |
- | phoneNumber | Generates a random phone number |
- | phoneNumberFormat | Generates a random phone number with requested format (Array index) |
- | phoneFormats | Generates a random phone number format |
-
-- faker.random
-
- | API | Description |
- | ------------- | --------------------------------------------------------------------------------- |
- | arrayElement | Takes an array and returns a random element of the array |
- | arrayElements | Takes an array and returns a subset with random elements of the array |
- | objectElement | Takes an object and returns a random key or value |
- | word | Generates a random word |
- | words | Generate `N` random words, with `N` defaulting to a random number between 1 and 3 |
- | locale | Generates a random locale |
- | alpha | Generates lower/upper alphabetic characters |
- | alphaNumeric | Generates alphanumeric characters |
-
-- faker.system
-
- | API | Description |
- | -------------- | ----------------------------------------------------------- |
- | fileName | Generates a random filenames without system path separators |
- | commonFileName | Generates a random filenames without system path separators |
- | mimeType | Generates a random mimetypes |
- | commonFileType | Generates a random commonly used file type |
- | commonFileExt | Generates a random commonly used file extension |
- | fileType | Get any file type available as mime-type |
- | fileExt | Generates a random file extension |
- | directoryPath | Generates a random directory path |
- | filePath | Generates a random unix fs file full path |
- | semver | Generate semantic version |
-
-- faker.time
-
- | API | Description |
- | ------ | ---------------------------------------- |
- | recent | Get recent timestamp in Unix time format |
-
-- faker.unique
-
-- faker.vehicle
-
- | API | Description |
- | ------------ | -------------------------------------------- |
- | vehicle | Generates a random vehicle name |
- | manufacturer | Generates a random vehicle manufacturer name |
- | model | Generates a random vehicle model name |
- | type | Generates a random vehicle type |
- | fuel | Generates a random vehicle fuel type |
- | vin | Generates a random vehicle vin number |
- | color | Generates a random vehicle color |
- | vrm | Generates a random vehicle vrm |
- | bicycle | Generates a random bicycle type |
-
-### Faker.fake()
-
-Faker contains a super useful generator method `Faker.fake` for combining faker API methods using a mustache string format.
+### faker.fake()
+
+Faker contains a super useful generator method `faker.fake` for combining faker API methods using a mustache string format.
**Example:**
diff --git a/docs/.vitepress/.gitignore b/docs/.vitepress/.gitignore
index 1af560a8a18..3b0c8abc1c9 100644
--- a/docs/.vitepress/.gitignore
+++ b/docs/.vitepress/.gitignore
@@ -1 +1 @@
-api-pages.mjs
+api-pages.ts
diff --git a/docs/.vitepress/config.mjs b/docs/.vitepress/config.ts
similarity index 52%
rename from docs/.vitepress/config.mjs
rename to docs/.vitepress/config.ts
index 60799a0eb4f..01394b84290 100644
--- a/docs/.vitepress/config.mjs
+++ b/docs/.vitepress/config.ts
@@ -1,28 +1,56 @@
+import type { DefaultTheme } from 'vitepress';
import { defineConfig } from 'vitepress';
-import { apiPages } from './api-pages.mjs';
+import { apiPages } from './api-pages';
-const nav = [
+const nav: DefaultTheme.NavItem[] = [
{ text: 'Guide', link: '/guide/' },
+ // { text: 'Playground', link: '/playground/' },
{
text: 'Ecosystem',
items: [
- { text: 'Discord', link: 'https://chat.fakerjs.dev' },
- { text: 'StackBlitz', link: 'https://fakerjs.dev/new' },
- { text: 'Twitter', link: 'https://twitter.com/faker_js' },
+ { text: 'Discord ', link: 'https://chat.fakerjs.dev' },
+ { text: 'StackBlitz ', link: 'https://fakerjs.dev/new' },
+ { text: 'Twitter ', link: 'https://twitter.com/faker_js' },
+ ],
+ },
+ {
+ text: 'About',
+ items: [
+ {
+ text: 'Announcements',
+ link: '/about/announcements',
+ },
+ {
+ text: 'Team',
+ link: '/about/team',
+ },
],
},
- // { text: 'Playground', link: '/playground/' },
];
-const sidebar = {
- '/': [
+const sidebar: DefaultTheme.MultiSideBarConfig = {
+ '/about': [
{
- text: 'Guide',
+ text: 'About',
children: [
{
- text: 'Recent Statement and FAQs',
- link: '/update.html',
+ text: 'Announcements',
+ link: '/about/announcements',
+ children: [
+ { text: '2022-01-14', link: '/about/announcements/2022-01-14' },
+ ],
},
+ {
+ text: 'Team',
+ link: '/about/team',
+ },
+ ],
+ },
+ ],
+ '/': [
+ {
+ text: 'Guide',
+ children: [
{
text: 'Getting Started',
link: '/guide/',
@@ -40,13 +68,10 @@ const sidebar = {
],
};
-// grab from process.env once this is building on netlify
-const algolia = {
- apiKey: '',
- indexName: '',
- searchParameters: {
- facetFilters: [''],
- },
+const algolia: DefaultTheme.AlgoliaSearchOptions = {
+ apiKey: process.env.API_KEY,
+ appId: process.env.APP_ID,
+ indexName: 'fakerjs',
};
const description =
@@ -62,27 +87,42 @@ export default defineConfig({
[
'meta',
{
- property: 'og:description',
+ name: 'og:description',
content: description,
},
+ ],
+ [
+ 'meta',
{
name: 'twitter:description',
content: description,
},
+ ],
+ [
+ 'meta',
{
name: 'description',
content: description,
},
+ ],
+ [
+ 'meta',
{
- property: 'og:image',
+ name: 'og:image',
content: image,
},
+ ],
+ [
+ 'meta',
{
- property: 'twitter:image',
+ name: 'twitter:image',
content: image,
},
+ ],
+ [
+ 'meta',
{
- property: 'twitter:card',
+ name: 'twitter:card',
content: 'summary_large_image',
},
],
@@ -96,7 +136,6 @@ export default defineConfig({
editLinkText: 'Suggest changes to this page',
nav,
sidebar,
- // TODO 2022-03-06: https://github.com/faker-js/faker/issues/222
- // algolia,
+ algolia,
},
});
diff --git a/docs/.vitepress/theme/components/index.mjs b/docs/.vitepress/theme/components/index.ts
similarity index 100%
rename from docs/.vitepress/theme/components/index.mjs
rename to docs/.vitepress/theme/components/index.ts
diff --git a/docs/.vitepress/theme/components/vue.d.ts b/docs/.vitepress/theme/components/vue.d.ts
new file mode 100644
index 00000000000..939fef480bc
--- /dev/null
+++ b/docs/.vitepress/theme/components/vue.d.ts
@@ -0,0 +1,4 @@
+declare module '*.vue' {
+ const component: any;
+ export default component;
+}
diff --git a/docs/.vitepress/theme/index.mjs b/docs/.vitepress/theme/index.ts
similarity index 100%
rename from docs/.vitepress/theme/index.mjs
rename to docs/.vitepress/theme/index.ts
diff --git a/docs/about/announcements.md b/docs/about/announcements.md
new file mode 100644
index 00000000000..9f00c334bbd
--- /dev/null
+++ b/docs/about/announcements.md
@@ -0,0 +1,7 @@
+---
+editLink: false
+---
+
+# Announcements
+
+- [2022-01-14 - An update from the Faker team](./announcements/2022-01-14)
diff --git a/docs/update.md b/docs/about/announcements/2022-01-14.md
similarity index 97%
rename from docs/update.md
rename to docs/about/announcements/2022-01-14.md
index a8a5ba4d58f..517f111210f 100644
--- a/docs/update.md
+++ b/docs/about/announcements/2022-01-14.md
@@ -40,7 +40,7 @@ We have eight maintainers currently.
- Damien Retzinger - [GitHub](https://github.com/damienwebdev), [Twitter](https://twitter.com/damienwebdev)
- Shinigami - [Github](https://github.com/Shinigami92), [Twitter](https://twitter.com/Shini_92)
-- Daniel Bannert - [Github](https://github.com/_prisis_), [Twitter](https://twitter.com/_prisis_)
+- Daniel Bannert - [Github](https://github.com/prisis), [Twitter](https://twitter.com/_prisis_)
- Erica Clark - [GitHub](https://github.com/clarkerican), [Twitter](https://twitter.com/clarkerican)
- Mo Mahallawy - [GitHub](https://github.com/mmahalwy), [Twitter](https://twitter.com/mmahalwy)
- griest - [GitLab](https://gitlab.com/griest)
@@ -68,7 +68,7 @@ He gave us permission to re-use his work to create **[fakerjs.dev](https://faker
9. Done a TON of issue triage and many, many PR reviews.
-

+
10. We've gotten in contact with the [Open Collective](https://opencollective.com) and discussed a transition plan for the project.
diff --git a/docs/about/team.md b/docs/about/team.md
new file mode 100644
index 00000000000..9013ee90db6
--- /dev/null
+++ b/docs/about/team.md
@@ -0,0 +1,9 @@
+---
+title: Team
+---
+
+
+
+
diff --git a/docs/about/team/TeamMember.ts b/docs/about/team/TeamMember.ts
new file mode 100644
index 00000000000..01fe3771296
--- /dev/null
+++ b/docs/about/team/TeamMember.ts
@@ -0,0 +1,7 @@
+export interface Member {
+ readonly name: string;
+ readonly github: string;
+ readonly gitlab?: string;
+ readonly twitter?: string;
+ readonly roles: readonly string[];
+}
diff --git a/docs/about/team/TeamMember.vue b/docs/about/team/TeamMember.vue
new file mode 100644
index 00000000000..03514a1f1f0
--- /dev/null
+++ b/docs/about/team/TeamMember.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
+
![]()
+
+
+
+ {{ member.name }}
+
+
+
+ Roles:
+
+ {{ role }}
+ ,
+
+
+
+
+
+
+
diff --git a/docs/about/team/TeamPage.vue b/docs/about/team/TeamPage.vue
new file mode 100644
index 00000000000..99801f17eba
--- /dev/null
+++ b/docs/about/team/TeamPage.vue
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
Honorable previous members
+
+
+
+
+
+
+
+
diff --git a/docs/about/team/members.json b/docs/about/team/members.json
new file mode 100644
index 00000000000..31018175204
--- /dev/null
+++ b/docs/about/team/members.json
@@ -0,0 +1,77 @@
+{
+ "core": [
+ {
+ "name": "Christopher Quadflieg",
+ "github": "Shinigami92",
+ "twitter": "Shini_92",
+ "roles": ["Code Maintainer"]
+ },
+ {
+ "name": "Damien Retzinger",
+ "github": "damienwebdev",
+ "twitter": "damienwebdev",
+ "roles": ["Advisor"]
+ },
+ {
+ "name": "Daniel Bannert",
+ "github": "prisis",
+ "twitter": "_prisis_",
+ "roles": ["Organization Owner"]
+ },
+ {
+ "name": "Daniel Theuke",
+ "github": "ST-DDT",
+ "roles": ["Code Maintainer", "Docs Automation"]
+ },
+ {
+ "name": "Erica Clark",
+ "github": "clarkerican",
+ "twitter": "clarkerican",
+ "roles": []
+ },
+ {
+ "name": "griest",
+ "github": "griest024",
+ "gitlab": "griest",
+ "roles": ["Code Reviewer"]
+ },
+ {
+ "name": "Jessica Sachs",
+ "github": "JessicaSachs",
+ "twitter": "_JessicaSachs",
+ "roles": ["Press Officer"]
+ }
+ ],
+ "contributors": [
+ {
+ "name": "Eric Cheng",
+ "github": "import-brain",
+ "roles": ["Triage", "Contributor"]
+ },
+ {
+ "name": "Leyla Jähnig",
+ "github": "xDivisionByZerox",
+ "roles": ["Contributor"]
+ },
+ {
+ "name": "Piotr Kuczynski",
+ "github": "pkuczynski",
+ "twitter": "PiotrKuczynski",
+ "roles": ["Contributor"]
+ }
+ ],
+ "previous": [
+ {
+ "name": "Mateus Dadalto",
+ "github": "MateusDadalto",
+ "twitter": "MateusD",
+ "roles": []
+ },
+ {
+ "name": "Mo Mahallawy",
+ "github": "mmahalwy",
+ "twitter": "mmahalwy",
+ "roles": []
+ }
+ ]
+}
diff --git a/docs/guide/index.md b/docs/guide/index.md
index fded3ac6c8d..61fe9a3dc61 100644
--- a/docs/guide/index.md
+++ b/docs/guide/index.md
@@ -71,7 +71,7 @@ const randomCard = faker.helpers.createCard(); // An object representing a rando
Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's `> 5 MiB` minified. **Please avoid deploying Faker in your web app.**
:::
-### Deno
+### CDN/Deno
```js
import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';
@@ -85,6 +85,17 @@ const randomCard = faker.helpers.createCard(); // random contact card containing
It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://cdn.skypack.dev/@faker-js/faker@v6.0.0"`. Add `?dts` to import with type definitions: `import { faker } from "https://cdn.skypack.dev/@faker-js/faker@v6.0.0?dts"`.
:::
+#### Alternative CDN links
+
+**esm:**
+
+- https://esm.sh/@faker-js/faker
+- https://cdn.jsdelivr.net/npm/@faker-js/faker/+esm
+
+**cjs:**
+
+- https://cdn.jsdelivr.net/npm/@faker-js/faker
+
## Community
If you have questions or need help, reach out to the community via [Discord](https://chat.fakerjs.dev) and [GitHub Discussions](https://github.com/faker-js/faker/discussions).
diff --git a/netlify.toml b/netlify.toml
index e876aa7274a..1095db518c2 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -20,3 +20,10 @@
to = "https://stackblitz.com/edit/faker-js-demo?file=index.ts"
status = 301
force = true
+
+# Redirect old update page to new announcement section
+[[redirects]]
+ from = "/update.html"
+ to = "https://fakerjs.dev/about/announcements/2022-01-14.html"
+ status = 301
+ force = true
diff --git a/package.json b/package.json
index da1c6526878..54aec8f7778 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@faker-js/faker",
- "version": "6.0.0-beta.0",
+ "version": "6.1.2",
"description": "Generate massive amounts of fake contextual data",
"keywords": [
"faker",
@@ -22,7 +22,7 @@
},
"license": "MIT",
"main": "dist/cjs/index.js",
- "module": "dist/esm/index.js",
+ "module": "dist/esm/index.mjs",
"types": "index.d.ts",
"typesVersions": {
">=4.0": {
@@ -33,14 +33,12 @@
},
"exports": {
".": {
- "node": "./dist/cjs/index.js",
- "es2015": "./dist/esm/index.js",
- "default": "./dist/esm/index.js"
+ "require": "./dist/cjs/index.js",
+ "import": "./dist/esm/index.mjs"
},
"./locale/*": {
- "node": "./dist/cjs/locale/*.js",
- "es2015": "./dist/esm/locale/*.js",
- "default": "./dist/esm/locale/*.js"
+ "require": "./dist/cjs/locale/*.js",
+ "import": "./dist/esm/locale/*.mjs"
},
"./package.json": "./package.json"
},
@@ -74,7 +72,8 @@
"docs:test:e2e:ci": "run-s docs:build:ci docs:test:e2e:run",
"docs:test:e2e:run": "run-p --race docs:serve \"cypress run\"",
"docs:test:e2e:open": "run-p --race docs:serve \"cypress open\"",
- "release": "standard-version"
+ "release": "standard-version",
+ "prepublishOnly": "pnpm run clean && pnpm install && pnpm run build"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged --concurrent false",
@@ -93,25 +92,25 @@
"@types/node": "~16.11.26",
"@types/prettier": "~2.4.4",
"@types/sanitize-html": "~2.6.2",
- "@types/validator": "~13.7.1",
- "@typescript-eslint/eslint-plugin": "~5.14.0",
- "@typescript-eslint/parser": "~5.14.0",
- "@vitest/ui": "~0.6.0",
+ "@types/validator": "~13.7.2",
+ "@typescript-eslint/eslint-plugin": "~5.17.0",
+ "@typescript-eslint/parser": "~5.17.0",
+ "@vitest/ui": "~0.8.4",
"c8": "~7.11.0",
"conventional-changelog-cli": "~2.2.2",
- "cypress": "~9.5.1",
- "esbuild": "~0.14.25",
- "eslint": "~8.11.0",
+ "cypress": "~9.5.3",
+ "esbuild": "~0.14.31",
+ "eslint": "~8.12.0",
"eslint-config-prettier": "~8.5.0",
- "eslint-define-config": "~1.2.5",
+ "eslint-define-config": "~1.3.0",
"eslint-gitignore": "~0.1.0",
- "eslint-plugin-jsdoc": "~38.0.2",
+ "eslint-plugin-jsdoc": "~38.1.6",
"eslint-plugin-prettier": "~4.0.0",
"esno": "~0.14.1",
- "lint-staged": "~12.3.5",
+ "lint-staged": "~12.3.7",
"npm-run-all": "~4.1.5",
"picocolors": "~1.0.0",
- "prettier": "2.5.1",
+ "prettier": "2.6.2",
"prettier-plugin-organize-imports": "~2.3.4",
"rimraf": "~3.0.2",
"sanitize-html": "~2.7.0",
@@ -119,15 +118,15 @@
"standard-version": "~9.3.2",
"typedoc": "~0.22.13",
"typedoc-plugin-missing-exports": "~0.22.6",
- "typescript": "~4.6.2",
+ "typescript": "~4.6.3",
"validator": "~13.7.0",
- "vite": "~2.8.6",
+ "vite": "~2.9.1",
"vitepress": "~0.22.3",
- "vitest": "~0.6.0"
+ "vitest": "~0.8.4"
},
- "packageManager": "pnpm@6.32.3",
+ "packageManager": "pnpm@6.32.4",
"engines": {
"node": ">=14.0.0",
- "npm": ">=7.0.0"
+ "npm": ">=6.0.0"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 31fd64331a9..f5f7f0f075c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5,25 +5,25 @@ specifiers:
'@types/node': ~16.11.26
'@types/prettier': ~2.4.4
'@types/sanitize-html': ~2.6.2
- '@types/validator': ~13.7.1
- '@typescript-eslint/eslint-plugin': ~5.14.0
- '@typescript-eslint/parser': ~5.14.0
- '@vitest/ui': ~0.6.0
+ '@types/validator': ~13.7.2
+ '@typescript-eslint/eslint-plugin': ~5.17.0
+ '@typescript-eslint/parser': ~5.17.0
+ '@vitest/ui': ~0.8.4
c8: ~7.11.0
conventional-changelog-cli: ~2.2.2
- cypress: ~9.5.1
- esbuild: ~0.14.25
- eslint: ~8.11.0
+ cypress: ~9.5.3
+ esbuild: ~0.14.31
+ eslint: ~8.12.0
eslint-config-prettier: ~8.5.0
- eslint-define-config: ~1.2.5
+ eslint-define-config: ~1.3.0
eslint-gitignore: ~0.1.0
- eslint-plugin-jsdoc: ~38.0.2
+ eslint-plugin-jsdoc: ~38.1.6
eslint-plugin-prettier: ~4.0.0
esno: ~0.14.1
- lint-staged: ~12.3.5
+ lint-staged: ~12.3.7
npm-run-all: ~4.1.5
picocolors: ~1.0.0
- prettier: 2.5.1
+ prettier: 2.6.2
prettier-plugin-organize-imports: ~2.3.4
rimraf: ~3.0.2
sanitize-html: ~2.7.0
@@ -31,48 +31,48 @@ specifiers:
standard-version: ~9.3.2
typedoc: ~0.22.13
typedoc-plugin-missing-exports: ~0.22.6
- typescript: ~4.6.2
+ typescript: ~4.6.3
validator: ~13.7.0
- vite: ~2.8.6
+ vite: ~2.9.1
vitepress: ~0.22.3
- vitest: ~0.6.0
+ vitest: ~0.8.4
devDependencies:
'@types/markdown-it': 12.2.3
'@types/node': 16.11.26
'@types/prettier': 2.4.4
'@types/sanitize-html': 2.6.2
- '@types/validator': 13.7.1
- '@typescript-eslint/eslint-plugin': 5.14.0_ace6f9e7722b813e21eaf2dc993bc413
- '@typescript-eslint/parser': 5.14.0_eslint@8.11.0+typescript@4.6.2
- '@vitest/ui': 0.6.0
+ '@types/validator': 13.7.2
+ '@typescript-eslint/eslint-plugin': 5.17.0_689ff565753ecf7c3328c07fad067df5
+ '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.6.3
+ '@vitest/ui': 0.8.4
c8: 7.11.0
conventional-changelog-cli: 2.2.2
- cypress: 9.5.1
- esbuild: 0.14.25
- eslint: 8.11.0
- eslint-config-prettier: 8.5.0_eslint@8.11.0
- eslint-define-config: 1.2.5
- eslint-gitignore: 0.1.0_eslint@8.11.0
- eslint-plugin-jsdoc: 38.0.2_eslint@8.11.0
- eslint-plugin-prettier: 4.0.0_c9d5adccfd1d43a8805a302169f6a967
+ cypress: 9.5.3
+ esbuild: 0.14.31
+ eslint: 8.12.0
+ eslint-config-prettier: 8.5.0_eslint@8.12.0
+ eslint-define-config: 1.3.0
+ eslint-gitignore: 0.1.0_eslint@8.12.0
+ eslint-plugin-jsdoc: 38.1.6_eslint@8.12.0
+ eslint-plugin-prettier: 4.0.0_f2c91d0f54113167d2bd9214a5ab5a36
esno: 0.14.1
- lint-staged: 12.3.5
+ lint-staged: 12.3.7
npm-run-all: 4.1.5
picocolors: 1.0.0
- prettier: 2.5.1
- prettier-plugin-organize-imports: 2.3.4_prettier@2.5.1+typescript@4.6.2
+ prettier: 2.6.2
+ prettier-plugin-organize-imports: 2.3.4_prettier@2.6.2+typescript@4.6.3
rimraf: 3.0.2
sanitize-html: 2.7.0
simple-git-hooks: 2.7.0
standard-version: 9.3.2
- typedoc: 0.22.13_typescript@4.6.2
+ typedoc: 0.22.13_typescript@4.6.3
typedoc-plugin-missing-exports: 0.22.6_typedoc@0.22.13
- typescript: 4.6.2
+ typescript: 4.6.3
validator: 13.7.0
- vite: 2.8.6
+ vite: 2.9.1
vitepress: 0.22.3
- vitest: 0.6.0_@vitest+ui@0.6.0+c8@7.11.0
+ vitest: 0.8.4_@vitest+ui@0.8.4+c8@7.11.0
packages:
@@ -82,108 +82,108 @@ packages:
'@algolia/autocomplete-shared': 1.5.2
dev: true
- /@algolia/autocomplete-preset-algolia/1.5.2_algoliasearch@4.12.2:
+ /@algolia/autocomplete-preset-algolia/1.5.2_algoliasearch@4.13.0:
resolution: {integrity: sha512-3MRYnYQFJyovANzSX2CToS6/5cfVjbLLqFsZTKcvF3abhQzxbqwwaMBlJtt620uBUOeMzhdfasKhCc40+RHiZw==}
peerDependencies:
'@algolia/client-search': ^4.9.1
algoliasearch: ^4.9.1
dependencies:
'@algolia/autocomplete-shared': 1.5.2
- algoliasearch: 4.12.2
+ algoliasearch: 4.13.0
dev: true
/@algolia/autocomplete-shared/1.5.2:
resolution: {integrity: sha512-ylQAYv5H0YKMfHgVWX0j0NmL8XBcAeeeVQUmppnnMtzDbDnca6CzhKj3Q8eF9cHCgcdTDdb5K+3aKyGWA0obug==}
dev: true
- /@algolia/cache-browser-local-storage/4.12.2:
- resolution: {integrity: sha512-z8LjFsQc0B6h6LEE3pkUGM4ErVktn6bkFbhnYbTccjmFVQ+wXFJd/D63e0WtaC+hwRB1xq8uKhkz9oojEKEsGA==}
+ /@algolia/cache-browser-local-storage/4.13.0:
+ resolution: {integrity: sha512-nj1vHRZauTqP/bluwkRIgEADEimqojJgoTRCel5f6q8WCa9Y8QeI4bpDQP28FoeKnDRYa3J5CauDlN466jqRhg==}
dependencies:
- '@algolia/cache-common': 4.12.2
+ '@algolia/cache-common': 4.13.0
dev: true
- /@algolia/cache-common/4.12.2:
- resolution: {integrity: sha512-r//r7MF0Na0HxD2BHnjWsDKuI72Z5UEf/Rb/8MC08XKBsjCwBihGxWxycjRcNGjNEIxJBsvRMIEOipcd9qD54g==}
+ /@algolia/cache-common/4.13.0:
+ resolution: {integrity: sha512-f9mdZjskCui/dA/fA/5a+6hZ7xnHaaZI5tM/Rw9X8rRB39SUlF/+o3P47onZ33n/AwkpSbi5QOyhs16wHd55kA==}
dev: true
- /@algolia/cache-in-memory/4.12.2:
- resolution: {integrity: sha512-opWpbBUloP1fcTG3wBDnAfcoyNXW5GFDgGtLXrSANdfnelPKkr3O8j01ZTkRlPIuBDR0izGZG8MVWMDlTf71Bw==}
+ /@algolia/cache-in-memory/4.13.0:
+ resolution: {integrity: sha512-hHdc+ahPiMM92CQMljmObE75laYzNFYLrNOu0Q3/eyvubZZRtY2SUsEEgyUEyzXruNdzrkcDxFYa7YpWBJYHAg==}
dependencies:
- '@algolia/cache-common': 4.12.2
+ '@algolia/cache-common': 4.13.0
dev: true
- /@algolia/client-account/4.12.2:
- resolution: {integrity: sha512-HZqEyeVVjzOlfoSUyc+7+ueEJmRgqSuC+hqQOGECYa5JVno4d8eRVuDAMOb87I2LOdg/WoFMcAtaaRq2gpfV/w==}
+ /@algolia/client-account/4.13.0:
+ resolution: {integrity: sha512-FzFqFt9b0g/LKszBDoEsW+dVBuUe1K3scp2Yf7q6pgHWM1WqyqUlARwVpLxqyc+LoyJkTxQftOKjyFUqddnPKA==}
dependencies:
- '@algolia/client-common': 4.12.2
- '@algolia/client-search': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/client-common': 4.13.0
+ '@algolia/client-search': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
- /@algolia/client-analytics/4.12.2:
- resolution: {integrity: sha512-7ktimzesu+vk3l+eG9w/nQh6/9AoIieCKmoiRIguKh6okGsaSBrcTHvUwIQEIiliqPuAFBk2M8eXYFqOZzwCZw==}
+ /@algolia/client-analytics/4.13.0:
+ resolution: {integrity: sha512-klmnoq2FIiiMHImkzOm+cGxqRLLu9CMHqFhbgSy9wtXZrqb8BBUIUE2VyBe7azzv1wKcxZV2RUyNOMpFqmnRZA==}
dependencies:
- '@algolia/client-common': 4.12.2
- '@algolia/client-search': 4.12.2
- '@algolia/requester-common': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/client-common': 4.13.0
+ '@algolia/client-search': 4.13.0
+ '@algolia/requester-common': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
- /@algolia/client-common/4.12.2:
- resolution: {integrity: sha512-+dTicT1lklwOpeoiDspUoRSQYHhrr2IzllrX89/WuTPEBm2eww1xurqrSTQYC0MuVeX1s9/i4k34Q0ZnspypWg==}
+ /@algolia/client-common/4.13.0:
+ resolution: {integrity: sha512-GoXfTp0kVcbgfSXOjfrxx+slSipMqGO9WnNWgeMmru5Ra09MDjrcdunsiiuzF0wua6INbIpBQFTC2Mi5lUNqGA==}
dependencies:
- '@algolia/requester-common': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/requester-common': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
- /@algolia/client-personalization/4.12.2:
- resolution: {integrity: sha512-JBW3vYFGIm5sAAy3cLUdmUCpmSAdreo5S1fERg7xgF6KyxGrwyy5BViTNWrOKG+av2yusk1wKydOYJ1Fbpbaxw==}
+ /@algolia/client-personalization/4.13.0:
+ resolution: {integrity: sha512-KneLz2WaehJmNfdr5yt2HQETpLaCYagRdWwIwkTqRVFCv4DxRQ2ChPVW9jeTj4YfAAhfzE6F8hn7wkQ/Jfj6ZA==}
dependencies:
- '@algolia/client-common': 4.12.2
- '@algolia/requester-common': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/client-common': 4.13.0
+ '@algolia/requester-common': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
- /@algolia/client-search/4.12.2:
- resolution: {integrity: sha512-JIqi14TgfEqAooNbSPBC1ZCk3Pnviqlaz9KofAqWBxSRTpPUFnU/XQCU5ihR0PC68SFVDnU/Y9cak/XotXPUeg==}
+ /@algolia/client-search/4.13.0:
+ resolution: {integrity: sha512-blgCKYbZh1NgJWzeGf+caKE32mo3j54NprOf0LZVCubQb3Kx37tk1Hc8SDs9bCAE8hUvf3cazMPIg7wscSxspA==}
dependencies:
- '@algolia/client-common': 4.12.2
- '@algolia/requester-common': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/client-common': 4.13.0
+ '@algolia/requester-common': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
- /@algolia/logger-common/4.12.2:
- resolution: {integrity: sha512-iOiJAymLjq137G7+8EQuUEkrgta0cZGMg6scp8s4hJ+X6k+6By4nyptdkCWYwKLsW/Xy927QcIhGlkWV78vQIQ==}
+ /@algolia/logger-common/4.13.0:
+ resolution: {integrity: sha512-8yqXk7rMtmQJ9wZiHOt/6d4/JDEg5VCk83gJ39I+X/pwUPzIsbKy9QiK4uJ3aJELKyoIiDT1hpYVt+5ia+94IA==}
dev: true
- /@algolia/logger-console/4.12.2:
- resolution: {integrity: sha512-veuQZyTSqHoHJtr9mLMnYeal9Mee6hCie4eqY+645VbeOrgT9p/kCMbKg5GLJGoLPlXGu7C0XpHyUj5k7/NQyw==}
+ /@algolia/logger-console/4.13.0:
+ resolution: {integrity: sha512-YepRg7w2/87L0vSXRfMND6VJ5d6699sFJBRWzZPOlek2p5fLxxK7O0VncYuc/IbVHEgeApvgXx0WgCEa38GVuQ==}
dependencies:
- '@algolia/logger-common': 4.12.2
+ '@algolia/logger-common': 4.13.0
dev: true
- /@algolia/requester-browser-xhr/4.12.2:
- resolution: {integrity: sha512-FpFdHNd81tS3zj6Glqd+lt+RV0ljPExKtx+QB+gani6HWZ9YlSCM+Zl82T4ibxN+hmkrMeAyT+TMzS0jiGhGyQ==}
+ /@algolia/requester-browser-xhr/4.13.0:
+ resolution: {integrity: sha512-Dj+bnoWR5MotrnjblzGKZ2kCdQi2cK/VzPURPnE616NU/il7Ypy6U6DLGZ/ZYz+tnwPa0yypNf21uqt84fOgrg==}
dependencies:
- '@algolia/requester-common': 4.12.2
+ '@algolia/requester-common': 4.13.0
dev: true
- /@algolia/requester-common/4.12.2:
- resolution: {integrity: sha512-4szj/lvDQf/u8EyyRBBRZD1ZkKDyLBbckLj7meQDlnbfwnW1UpLwpB2l3XJ9wDmDSftGxUCeTl5oMFe4z9OEvQ==}
+ /@algolia/requester-common/4.13.0:
+ resolution: {integrity: sha512-BRTDj53ecK+gn7ugukDWOOcBRul59C4NblCHqj4Zm5msd5UnHFjd/sGX+RLOEoFMhetILAnmg6wMrRrQVac9vw==}
dev: true
- /@algolia/requester-node-http/4.12.2:
- resolution: {integrity: sha512-UXfJNZt2KMwjBjiOa3cJ/PyoXWZa/F1vy6rdyG4xQeZDcLbqKP3O2b+bOJcGPmFbmdwBhtAyMVLt+hvAvAVfOw==}
+ /@algolia/requester-node-http/4.13.0:
+ resolution: {integrity: sha512-9b+3O4QFU4azLhGMrZAr/uZPydvzOR4aEZfSL8ZrpLZ7fbbqTO0S/5EVko+QIgglRAtVwxvf8UJ1wzTD2jvKxQ==}
dependencies:
- '@algolia/requester-common': 4.12.2
+ '@algolia/requester-common': 4.13.0
dev: true
- /@algolia/transporter/4.12.2:
- resolution: {integrity: sha512-PUq79if4CukXsm27ymTQ3eD3juSvMcyJmt6mxCkSFE0zQRL4ert61HBlNH6S9y/quUVe3g7oggfHq3d5pdpqZA==}
+ /@algolia/transporter/4.13.0:
+ resolution: {integrity: sha512-8tSQYE+ykQENAdeZdofvtkOr5uJ9VcQSWgRhQ9h01AehtBIPAczk/b2CLrMsw5yQZziLs5cZ3pJ3478yI+urhA==}
dependencies:
- '@algolia/cache-common': 4.12.2
- '@algolia/logger-common': 4.12.2
- '@algolia/requester-common': 4.12.2
+ '@algolia/cache-common': 4.13.0
+ '@algolia/logger-common': 4.13.0
+ '@algolia/requester-common': 4.13.0
dev: true
/@babel/code-frame/7.16.7:
@@ -207,8 +207,8 @@ packages:
js-tokens: 4.0.0
dev: true
- /@babel/parser/7.17.3:
- resolution: {integrity: sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA==}
+ /@babel/parser/7.17.8:
+ resolution: {integrity: sha512-BoHhDJrJXqcg+ZL16Xv39H9n+AqJ4pcDrQBGZN+wHxIysrLZ3/ECwCBUch/1zUNhnsXULcONU3Ei5Hmkfk6kiQ==}
engines: {node: '>=6.0.0'}
hasBin: true
dev: true
@@ -232,7 +232,7 @@ packages:
is-typedarray: 1.0.0
isstream: 0.1.2
json-stringify-safe: 5.0.1
- mime-types: 2.1.34
+ mime-types: 2.1.35
performance-now: 2.1.0
qs: 6.5.3
safe-buffer: 5.2.1
@@ -256,7 +256,7 @@ packages:
resolution: {integrity: sha512-j3tUJWlgW3slYqzGB8fm7y05kh2qqrIK1dZOXHeMUm/5gdKE85fiz/ltfCPMDFb/MXF+bLZChJXSMzqY0Ck30Q==}
dependencies:
'@docsearch/react': 3.0.0
- preact: 10.6.6
+ preact: 10.7.0
transitivePeerDependencies:
- '@algolia/client-search'
- '@types/react'
@@ -272,20 +272,20 @@ packages:
react-dom: '>= 16.8.0 < 18.0.0'
dependencies:
'@algolia/autocomplete-core': 1.5.2
- '@algolia/autocomplete-preset-algolia': 1.5.2_algoliasearch@4.12.2
+ '@algolia/autocomplete-preset-algolia': 1.5.2_algoliasearch@4.13.0
'@docsearch/css': 3.0.0
- algoliasearch: 4.12.2
+ algoliasearch: 4.13.0
transitivePeerDependencies:
- '@algolia/client-search'
dev: true
- /@es-joy/jsdoccomment/0.20.1:
- resolution: {integrity: sha512-oeJK41dcdqkvdZy/HctKklJNkt/jh+av3PZARrZEl+fs/8HaHeeYoAvEwOV0u5I6bArTF17JEsTZMY359e/nfQ==}
+ /@es-joy/jsdoccomment/0.22.1:
+ resolution: {integrity: sha512-/WMkqLYfwCf0waCAMC8Eddt3iAOdghkDF5vmyKEu8pfO66KRFY1L15yks8mfgURiwOAOJpAQ3blvB3Znj6ZwBw==}
engines: {node: ^12 || ^14 || ^16 || ^17}
dependencies:
- comment-parser: 1.3.0
+ comment-parser: 1.3.1
esquery: 1.4.0
- jsdoc-type-pratt-parser: 2.2.3
+ jsdoc-type-pratt-parser: 2.2.5
dev: true
/@eslint/eslintrc/1.2.1:
@@ -293,9 +293,9 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
ajv: 6.12.6
- debug: 4.3.3
+ debug: 4.3.4
espree: 9.3.1
- globals: 13.12.1
+ globals: 13.13.0
ignore: 5.2.0
import-fresh: 3.3.0
js-yaml: 4.1.0
@@ -310,7 +310,7 @@ packages:
engines: {node: '>=10.10.0'}
dependencies:
'@humanwhocodes/object-schema': 1.2.1
- debug: 4.3.3
+ debug: 4.3.4
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -369,8 +369,8 @@ packages:
resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==}
dev: true
- /@types/json-schema/7.0.9:
- resolution: {integrity: sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==}
+ /@types/json-schema/7.0.11:
+ resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==}
dev: true
/@types/linkify-it/3.0.2:
@@ -422,8 +422,8 @@ packages:
resolution: {integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==}
dev: true
- /@types/validator/13.7.1:
- resolution: {integrity: sha512-I6OUIZ5cYRk5lp14xSOAiXjWrfVoMZVjDuevBYgQDYzZIjsf2CAISpEcXOkFAtpAHbmWIDLcZObejqny/9xq5Q==}
+ /@types/validator/13.7.2:
+ resolution: {integrity: sha512-KFcchQ3h0OPQgFirBRPZr5F/sVjxZsOrQHedj3zi8AH3Zv/hOLx2OLR4hxR5HcfoU+33n69ZuOfzthKVdMoTiw==}
dev: true
/@types/yauzl/2.9.2:
@@ -434,8 +434,8 @@ packages:
dev: true
optional: true
- /@typescript-eslint/eslint-plugin/5.14.0_ace6f9e7722b813e21eaf2dc993bc413:
- resolution: {integrity: sha512-ir0wYI4FfFUDfLcuwKzIH7sMVA+db7WYen47iRSaCGl+HMAZI9fpBwfDo45ZALD3A45ZGyHWDNLhbg8tZrMX4w==}
+ /@typescript-eslint/eslint-plugin/5.17.0_689ff565753ecf7c3328c07fad067df5:
+ resolution: {integrity: sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
'@typescript-eslint/parser': ^5.0.0
@@ -445,24 +445,24 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/parser': 5.14.0_eslint@8.11.0+typescript@4.6.2
- '@typescript-eslint/scope-manager': 5.14.0
- '@typescript-eslint/type-utils': 5.14.0_eslint@8.11.0+typescript@4.6.2
- '@typescript-eslint/utils': 5.14.0_eslint@8.11.0+typescript@4.6.2
- debug: 4.3.3
- eslint: 8.11.0
+ '@typescript-eslint/parser': 5.17.0_eslint@8.12.0+typescript@4.6.3
+ '@typescript-eslint/scope-manager': 5.17.0
+ '@typescript-eslint/type-utils': 5.17.0_eslint@8.12.0+typescript@4.6.3
+ '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.6.3
+ debug: 4.3.4
+ eslint: 8.12.0
functional-red-black-tree: 1.0.1
ignore: 5.2.0
regexpp: 3.2.0
semver: 7.3.5
- tsutils: 3.21.0_typescript@4.6.2
- typescript: 4.6.2
+ tsutils: 3.21.0_typescript@4.6.3
+ typescript: 4.6.3
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/parser/5.14.0_eslint@8.11.0+typescript@4.6.2:
- resolution: {integrity: sha512-aHJN8/FuIy1Zvqk4U/gcO/fxeMKyoSv/rS46UXMXOJKVsLQ+iYPuXNbpbH7cBLcpSbmyyFbwrniLx5+kutu1pw==}
+ /@typescript-eslint/parser/5.17.0_eslint@8.12.0+typescript@4.6.3:
+ resolution: {integrity: sha512-aRzW9Jg5Rlj2t2/crzhA2f23SIYFlF9mchGudyP0uiD6SenIxzKoLjwzHbafgHn39dNV/TV7xwQkLfFTZlJ4ig==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
@@ -471,26 +471,26 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/scope-manager': 5.14.0
- '@typescript-eslint/types': 5.14.0
- '@typescript-eslint/typescript-estree': 5.14.0_typescript@4.6.2
- debug: 4.3.3
- eslint: 8.11.0
- typescript: 4.6.2
+ '@typescript-eslint/scope-manager': 5.17.0
+ '@typescript-eslint/types': 5.17.0
+ '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.6.3
+ debug: 4.3.4
+ eslint: 8.12.0
+ typescript: 4.6.3
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/scope-manager/5.14.0:
- resolution: {integrity: sha512-LazdcMlGnv+xUc5R4qIlqH0OWARyl2kaP8pVCS39qSL3Pd1F7mI10DbdXeARcE62sVQE4fHNvEqMWsypWO+yEw==}
+ /@typescript-eslint/scope-manager/5.17.0:
+ resolution: {integrity: sha512-062iCYQF/doQ9T2WWfJohQKKN1zmmXVfAcS3xaiialiw8ZUGy05Em6QVNYJGO34/sU1a7a+90U3dUNfqUDHr3w==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
- '@typescript-eslint/types': 5.14.0
- '@typescript-eslint/visitor-keys': 5.14.0
+ '@typescript-eslint/types': 5.17.0
+ '@typescript-eslint/visitor-keys': 5.17.0
dev: true
- /@typescript-eslint/type-utils/5.14.0_eslint@8.11.0+typescript@4.6.2:
- resolution: {integrity: sha512-d4PTJxsqaUpv8iERTDSQBKUCV7Q5yyXjqXUl3XF7Sd9ogNLuKLkxz82qxokqQ4jXdTPZudWpmNtr/JjbbvUixw==}
+ /@typescript-eslint/type-utils/5.17.0_eslint@8.12.0+typescript@4.6.3:
+ resolution: {integrity: sha512-3hU0RynUIlEuqMJA7dragb0/75gZmwNwFf/QJokWzPehTZousP/MNifVSgjxNcDCkM5HI2K22TjQWUmmHUINSg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: '*'
@@ -499,22 +499,22 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/utils': 5.14.0_eslint@8.11.0+typescript@4.6.2
- debug: 4.3.3
- eslint: 8.11.0
- tsutils: 3.21.0_typescript@4.6.2
- typescript: 4.6.2
+ '@typescript-eslint/utils': 5.17.0_eslint@8.12.0+typescript@4.6.3
+ debug: 4.3.4
+ eslint: 8.12.0
+ tsutils: 3.21.0_typescript@4.6.3
+ typescript: 4.6.3
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/types/5.14.0:
- resolution: {integrity: sha512-BR6Y9eE9360LNnW3eEUqAg6HxS9Q35kSIs4rp4vNHRdfg0s+/PgHgskvu5DFTM7G5VKAVjuyaN476LCPrdA7Mw==}
+ /@typescript-eslint/types/5.17.0:
+ resolution: {integrity: sha512-AgQ4rWzmCxOZLioFEjlzOI3Ch8giDWx8aUDxyNw9iOeCvD3GEYAB7dxWGQy4T/rPVe8iPmu73jPHuaSqcjKvxw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
- /@typescript-eslint/typescript-estree/5.14.0_typescript@4.6.2:
- resolution: {integrity: sha512-QGnxvROrCVtLQ1724GLTHBTR0lZVu13izOp9njRvMkCBgWX26PKvmMP8k82nmXBRD3DQcFFq2oj3cKDwr0FaUA==}
+ /@typescript-eslint/typescript-estree/5.17.0_typescript@4.6.3:
+ resolution: {integrity: sha512-X1gtjEcmM7Je+qJRhq7ZAAaNXYhTgqMkR10euC4Si6PIjb+kwEQHSxGazXUQXFyqfEXdkGf6JijUu5R0uceQzg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
typescript: '*'
@@ -522,57 +522,57 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/types': 5.14.0
- '@typescript-eslint/visitor-keys': 5.14.0
- debug: 4.3.3
+ '@typescript-eslint/types': 5.17.0
+ '@typescript-eslint/visitor-keys': 5.17.0
+ debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.5
- tsutils: 3.21.0_typescript@4.6.2
- typescript: 4.6.2
+ tsutils: 3.21.0_typescript@4.6.3
+ typescript: 4.6.3
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/utils/5.14.0_eslint@8.11.0+typescript@4.6.2:
- resolution: {integrity: sha512-EHwlII5mvUA0UsKYnVzySb/5EE/t03duUTweVy8Zqt3UQXBrpEVY144OTceFKaOe4xQXZJrkptCf7PjEBeGK4w==}
+ /@typescript-eslint/utils/5.17.0_eslint@8.12.0+typescript@4.6.3:
+ resolution: {integrity: sha512-DVvndq1QoxQH+hFv+MUQHrrWZ7gQ5KcJzyjhzcqB1Y2Xes1UQQkTRPUfRpqhS8mhTWsSb2+iyvDW1Lef5DD7vA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
dependencies:
- '@types/json-schema': 7.0.9
- '@typescript-eslint/scope-manager': 5.14.0
- '@typescript-eslint/types': 5.14.0
- '@typescript-eslint/typescript-estree': 5.14.0_typescript@4.6.2
- eslint: 8.11.0
+ '@types/json-schema': 7.0.11
+ '@typescript-eslint/scope-manager': 5.17.0
+ '@typescript-eslint/types': 5.17.0
+ '@typescript-eslint/typescript-estree': 5.17.0_typescript@4.6.3
+ eslint: 8.12.0
eslint-scope: 5.1.1
- eslint-utils: 3.0.0_eslint@8.11.0
+ eslint-utils: 3.0.0_eslint@8.12.0
transitivePeerDependencies:
- supports-color
- typescript
dev: true
- /@typescript-eslint/visitor-keys/5.14.0:
- resolution: {integrity: sha512-yL0XxfzR94UEkjBqyymMLgCBdojzEuy/eim7N9/RIcTNxpJudAcqsU8eRyfzBbcEzGoPWfdM3AGak3cN08WOIw==}
+ /@typescript-eslint/visitor-keys/5.17.0:
+ resolution: {integrity: sha512-6K/zlc4OfCagUu7Am/BD5k8PSWQOgh34Nrv9Rxe2tBzlJ7uOeJ/h7ugCGDCeEZHT6k2CJBhbk9IsbkPI0uvUkA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dependencies:
- '@typescript-eslint/types': 5.14.0
+ '@typescript-eslint/types': 5.17.0
eslint-visitor-keys: 3.3.0
dev: true
- /@vitejs/plugin-vue/2.2.4_vite@2.8.6+vue@3.2.31:
- resolution: {integrity: sha512-ev9AOlp0ljCaDkFZF3JwC/pD2N4Hh+r5srl5JHM6BKg5+99jiiK0rE/XaRs3pVm1wzyKkjUy/StBSoXX5fFzcw==}
+ /@vitejs/plugin-vue/2.3.1_vite@2.9.1+vue@3.2.31:
+ resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==}
engines: {node: '>=12.0.0'}
peerDependencies:
vite: ^2.5.10
vue: ^3.2.25
dependencies:
- vite: 2.8.6
+ vite: 2.9.1
vue: 3.2.31
dev: true
- /@vitest/ui/0.6.0:
- resolution: {integrity: sha512-hune6gWckOm9sIo5vY0u3wpUZRpo3o0bALmvQcIzbL6IMMEbK9sW7AXY4Pu2XGq2IqHWoEKqdY8aantPJzfOHg==}
+ /@vitest/ui/0.8.4:
+ resolution: {integrity: sha512-ipbw8XyS6jt+H1d2gCjuc6PBr1clCk/NyfbkgDhFXkBYK0ST5H192ZDq4sx3nqOat2oPH0/OyQsb1FlX7DBG3A==}
dependencies:
sirv: 2.0.2
dev: true
@@ -580,7 +580,7 @@ packages:
/@vue/compiler-core/3.2.31:
resolution: {integrity: sha512-aKno00qoA4o+V/kR6i/pE+aP+esng5siNAVQ422TkBNM6qA4veXiZbSe8OTXHXquEi/f6Akc+nLfB4JGfe4/WQ==}
dependencies:
- '@babel/parser': 7.17.3
+ '@babel/parser': 7.17.8
'@vue/shared': 3.2.31
estree-walker: 2.0.2
source-map: 0.6.1
@@ -596,7 +596,7 @@ packages:
/@vue/compiler-sfc/3.2.31:
resolution: {integrity: sha512-748adc9msSPGzXgibHiO6T7RWgfnDcVQD+VVwYgSsyyY8Ans64tALHZANrKtOzvkwznV/F4H7OAod/jIlp/dkQ==}
dependencies:
- '@babel/parser': 7.17.3
+ '@babel/parser': 7.17.8
'@vue/compiler-core': 3.2.31
'@vue/compiler-dom': 3.2.31
'@vue/compiler-ssr': 3.2.31
@@ -604,7 +604,7 @@ packages:
'@vue/shared': 3.2.31
estree-walker: 2.0.2
magic-string: 0.25.9
- postcss: 8.4.7
+ postcss: 8.4.12
source-map: 0.6.1
dev: true
@@ -618,7 +618,7 @@ packages:
/@vue/reactivity-transform/3.2.31:
resolution: {integrity: sha512-uS4l4z/W7wXdI+Va5pgVxBJ345wyGFKvpPYtdSgvfJfX/x2Ymm6ophQlXXB6acqGHtXuBqNyyO3zVp9b1r0MOA==}
dependencies:
- '@babel/parser': 7.17.3
+ '@babel/parser': 7.17.8
'@vue/compiler-core': 3.2.31
'@vue/shared': 3.2.31
estree-walker: 2.0.2
@@ -703,23 +703,23 @@ packages:
uri-js: 4.4.1
dev: true
- /algoliasearch/4.12.2:
- resolution: {integrity: sha512-bn1P9+V415zeDQJtXn+1SwuwedEAv9/LJAxt8XwR6ygH/sMwaHSm2hpkz8wIbCBt/tKQ43TL672Kyxzv5PwGgQ==}
+ /algoliasearch/4.13.0:
+ resolution: {integrity: sha512-oHv4faI1Vl2s+YC0YquwkK/TsaJs79g2JFg5FDm2rKN12VItPTAeQ7hyJMHarOPPYuCnNC5kixbtcqvb21wchw==}
dependencies:
- '@algolia/cache-browser-local-storage': 4.12.2
- '@algolia/cache-common': 4.12.2
- '@algolia/cache-in-memory': 4.12.2
- '@algolia/client-account': 4.12.2
- '@algolia/client-analytics': 4.12.2
- '@algolia/client-common': 4.12.2
- '@algolia/client-personalization': 4.12.2
- '@algolia/client-search': 4.12.2
- '@algolia/logger-common': 4.12.2
- '@algolia/logger-console': 4.12.2
- '@algolia/requester-browser-xhr': 4.12.2
- '@algolia/requester-common': 4.12.2
- '@algolia/requester-node-http': 4.12.2
- '@algolia/transporter': 4.12.2
+ '@algolia/cache-browser-local-storage': 4.13.0
+ '@algolia/cache-common': 4.13.0
+ '@algolia/cache-in-memory': 4.13.0
+ '@algolia/client-account': 4.13.0
+ '@algolia/client-analytics': 4.13.0
+ '@algolia/client-common': 4.13.0
+ '@algolia/client-personalization': 4.13.0
+ '@algolia/client-search': 4.13.0
+ '@algolia/logger-common': 4.13.0
+ '@algolia/logger-console': 4.13.0
+ '@algolia/requester-browser-xhr': 4.13.0
+ '@algolia/requester-common': 4.13.0
+ '@algolia/requester-node-http': 4.13.0
+ '@algolia/transporter': 4.13.0
dev: true
/ansi-colors/4.1.1:
@@ -786,7 +786,7 @@ packages:
dependencies:
call-bind: 1.0.2
define-properties: 1.1.3
- es-abstract: 1.19.1
+ es-abstract: 1.19.2
dev: true
/arrify/1.0.1:
@@ -892,8 +892,8 @@ packages:
ieee754: 1.2.1
dev: true
- /builtins/4.0.0:
- resolution: {integrity: sha512-qC0E2Dxgou1IHhvJSLwGDSTvokbRovU5zZFuDY6oY8Y2lF3nGt5Ad8YZK7GMtqzY84Wu7pXTPeHQeHcXSXsRhw==}
+ /builtins/4.1.0:
+ resolution: {integrity: sha512-1bPRZQtmKaO6h7qV1YHXNtr6nCK28k0Zo95KM4dXfILcZZwoHJBN1m3lfLv9LPkcOZlrSr+J1bzMaZFO98Yq0w==}
dependencies:
semver: 7.3.5
dev: true
@@ -1089,8 +1089,8 @@ packages:
engines: {node: '>= 12'}
dev: true
- /comment-parser/1.3.0:
- resolution: {integrity: sha512-hRpmWIKgzd81vn0ydoWoyPoALEOnF4wt8yKD35Ib1D6XC2siLiYaiqfGkYrunuKdsXGwpBpHU3+9r+RVw2NZfA==}
+ /comment-parser/1.3.1:
+ resolution: {integrity: sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==}
engines: {node: '>= 12.0.0'}
dev: true
@@ -1361,8 +1361,8 @@ packages:
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==}
dev: true
- /cypress/9.5.1:
- resolution: {integrity: sha512-H7lUWB3Svr44gz1rNnj941xmdsCljXoJa2cDneAltjI9leKLMQLm30x6jLlpQ730tiVtIbW5HdUmBzPzwzfUQg==}
+ /cypress/9.5.3:
+ resolution: {integrity: sha512-ItelIVmqMTnKYbo1JrErhsGgQGjWOxCpHT1TfMvwnIXKXN/OSlPjEK7rbCLYDZhejQL99PmUqul7XORI24Ik0A==}
engines: {node: '>=12.0.0'}
hasBin: true
requiresBuild: true
@@ -1383,8 +1383,8 @@ packages:
cli-table3: 0.6.1
commander: 5.1.0
common-tags: 1.8.2
- dayjs: 1.10.8
- debug: 4.3.3_supports-color@8.1.1
+ dayjs: 1.11.0
+ debug: 4.3.4_supports-color@8.1.1
enquirer: 2.3.6
eventemitter2: 6.4.5
execa: 4.1.0
@@ -1399,7 +1399,7 @@ packages:
listr2: 3.14.0_enquirer@2.3.6
lodash: 4.17.21
log-symbols: 4.1.0
- minimist: 1.2.5
+ minimist: 1.2.6
ospath: 1.2.2
pretty-bytes: 5.6.0
proxy-from-env: 1.0.0
@@ -1427,8 +1427,8 @@ packages:
resolution: {integrity: sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==}
dev: true
- /dayjs/1.10.8:
- resolution: {integrity: sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==}
+ /dayjs/1.11.0:
+ resolution: {integrity: sha512-JLC809s6Y948/FuCZPm5IX8rRhQwOiyMb2TfVVQEixG7P8Lm/gt5S7yoQZmC8x1UehI9Pb7sksEt4xx14m+7Ug==}
dev: true
/debug/3.2.7:
@@ -1437,8 +1437,8 @@ packages:
ms: 2.1.3
dev: true
- /debug/4.3.3:
- resolution: {integrity: sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==}
+ /debug/4.3.4:
+ resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
@@ -1449,8 +1449,8 @@ packages:
ms: 2.1.2
dev: true
- /debug/4.3.3_supports-color@8.1.1:
- resolution: {integrity: sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==}
+ /debug/4.3.4_supports-color@8.1.1:
+ resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
@@ -1462,8 +1462,8 @@ packages:
supports-color: 8.1.1
dev: true
- /debug/4.3.3_supports-color@9.2.1:
- resolution: {integrity: sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==}
+ /debug/4.3.4_supports-color@9.2.2:
+ resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
@@ -1472,7 +1472,7 @@ packages:
optional: true
dependencies:
ms: 2.1.2
- supports-color: 9.2.1
+ supports-color: 9.2.2
dev: true
/decamelize-keys/1.1.0:
@@ -1544,7 +1544,7 @@ packages:
resolution: {integrity: sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==}
dependencies:
domelementtype: 2.2.0
- domhandler: 4.3.0
+ domhandler: 4.3.1
entities: 2.2.0
dev: true
@@ -1552,8 +1552,8 @@ packages:
resolution: {integrity: sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==}
dev: true
- /domhandler/4.3.0:
- resolution: {integrity: sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==}
+ /domhandler/4.3.1:
+ resolution: {integrity: sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==}
engines: {node: '>= 4'}
dependencies:
domelementtype: 2.2.0
@@ -1564,7 +1564,7 @@ packages:
dependencies:
dom-serializer: 1.3.2
domelementtype: 2.2.0
- domhandler: 4.3.0
+ domhandler: 4.3.1
dev: true
/dot-prop/5.3.0:
@@ -1624,8 +1624,8 @@ packages:
is-arrayish: 0.2.1
dev: true
- /es-abstract/1.19.1:
- resolution: {integrity: sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==}
+ /es-abstract/1.19.2:
+ resolution: {integrity: sha512-gfSBJoZdlL2xRiOCy0g8gLMryhoe1TlimjzU99L/31Z8QEGIhVQI+EWwt5lT+AuU9SnorVupXFqqOGqGfsyO6w==}
engines: {node: '>= 0.4'}
dependencies:
call-bind: 1.0.2
@@ -1639,7 +1639,7 @@ packages:
is-callable: 1.2.4
is-negative-zero: 2.0.2
is-regex: 1.1.4
- is-shared-array-buffer: 1.0.1
+ is-shared-array-buffer: 1.0.2
is-string: 1.0.7
is-weakref: 1.0.2
object-inspect: 1.12.0
@@ -1659,8 +1659,8 @@ packages:
is-symbol: 1.0.4
dev: true
- /esbuild-android-64/0.14.25:
- resolution: {integrity: sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==}
+ /esbuild-android-64/0.14.31:
+ resolution: {integrity: sha512-MYkuJ91w07nGmr4EouejOZK2j/f5TCnsKxY8vRr2+wpKKfHD1LTJK28VbZa+y1+AL7v1V9G98ezTUwsV3CmXNw==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
@@ -1668,8 +1668,8 @@ packages:
dev: true
optional: true
- /esbuild-android-arm64/0.14.25:
- resolution: {integrity: sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==}
+ /esbuild-android-arm64/0.14.31:
+ resolution: {integrity: sha512-0rkH/35s7ZVcsw6nS0IAkR0dekSbjZGWdlOAf3jV0lGoPqqw0x6/TmaV9w7DQgUERTH1ApmPlpAMU4kVkCq9Jg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
@@ -1677,8 +1677,8 @@ packages:
dev: true
optional: true
- /esbuild-darwin-64/0.14.25:
- resolution: {integrity: sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==}
+ /esbuild-darwin-64/0.14.31:
+ resolution: {integrity: sha512-kP6xPZHxtJa36Hb0jC05L3VzQSZBW2f3bpnQS20czXTRGEmM2GDiYpGdI5g2QYaw6vC4PYXjnigq8usd9g9jnQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
@@ -1686,8 +1686,8 @@ packages:
dev: true
optional: true
- /esbuild-darwin-arm64/0.14.25:
- resolution: {integrity: sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==}
+ /esbuild-darwin-arm64/0.14.31:
+ resolution: {integrity: sha512-1ZMog4hkNsdBGtDDtsftUqX6S9N52gEx4vX5aVehsSptgoBFIar1XrPiBTQty7YNH+bJasTpSVaZQgElCVvPKQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
@@ -1695,8 +1695,8 @@ packages:
dev: true
optional: true
- /esbuild-freebsd-64/0.14.25:
- resolution: {integrity: sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==}
+ /esbuild-freebsd-64/0.14.31:
+ resolution: {integrity: sha512-Zo0BYj7QpVFWoUpkv6Ng0RO2eJ4zk/WDaHMO88+jr5HuYmxsOre0imgwaZVPquTuJnCvL1G48BFucJ3tFflSeQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
@@ -1704,8 +1704,8 @@ packages:
dev: true
optional: true
- /esbuild-freebsd-arm64/0.14.25:
- resolution: {integrity: sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==}
+ /esbuild-freebsd-arm64/0.14.31:
+ resolution: {integrity: sha512-t85bS6jbRpmdjr4pdr/FY/fpx8lo1vv9S7BAs2EsXKJQhRDMIiC3QW+k2acYJoRuqirlvJcJVFQGCq/PfyC1kA==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
@@ -1713,8 +1713,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-32/0.14.25:
- resolution: {integrity: sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==}
+ /esbuild-linux-32/0.14.31:
+ resolution: {integrity: sha512-XYtOk/GodSkv+UOYVwryGpGPuFnszsMvRMKq6cIUfFfdssHuKDsU9IZveyCG44J106J39ABenQ5EetbYtVJHUw==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
@@ -1722,8 +1722,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-64/0.14.25:
- resolution: {integrity: sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==}
+ /esbuild-linux-64/0.14.31:
+ resolution: {integrity: sha512-Zf9CZxAxaXWHLqCg/QZ/hs0RU0XV3IBxV+ENQzy00S4QOTnZAvSLgPciILHHrVJ0lPIlb4XzAqlLM5y6iI2LIw==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
@@ -1731,8 +1731,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-arm/0.14.25:
- resolution: {integrity: sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==}
+ /esbuild-linux-arm/0.14.31:
+ resolution: {integrity: sha512-RpiaeHPRlgCCDskxoyIsI49BhcDtZ4cl8+SLffizDm0yMNWP538SUg0ezQ2TTOPj3/svaGIbkRDwYtAon0Sjkg==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
@@ -1740,8 +1740,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-arm64/0.14.25:
- resolution: {integrity: sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==}
+ /esbuild-linux-arm64/0.14.31:
+ resolution: {integrity: sha512-V/H0tv+xpQ9IOHM+o85oCKNNidIEc5CcnDWl0V+hPd2F03dqdbFkWPBGphx8rD4JSQn6UefUQ1iH7y1qIzO8Fw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
@@ -1749,8 +1749,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-mips64le/0.14.25:
- resolution: {integrity: sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==}
+ /esbuild-linux-mips64le/0.14.31:
+ resolution: {integrity: sha512-9/oBfAckInRuUg6AEgdCLLn6KJ6UOJDOLmUinTsReVSg6AfV6wxYQJq9iQM2idRogP7GUpomJ+bvCdWXpotQRQ==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
@@ -1758,8 +1758,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-ppc64le/0.14.25:
- resolution: {integrity: sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==}
+ /esbuild-linux-ppc64le/0.14.31:
+ resolution: {integrity: sha512-NMcb14Pg+8q8raGkzor9/R3vQwKzgxE3694BtO2SDLBwJuL2C1dQ1ZtM1t7ZvArQBgT8RiZVxb0/3fD+qGNk7g==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
@@ -1767,8 +1767,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-riscv64/0.14.25:
- resolution: {integrity: sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==}
+ /esbuild-linux-riscv64/0.14.31:
+ resolution: {integrity: sha512-l13yvmsVfawAnoYfcpuvml+nTlrOmtdceXYufSkXl2DOb0JKcuR6ARlAzuQCDcpo49SOJy1cCxpwlOIsUQBfzA==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
@@ -1776,8 +1776,8 @@ packages:
dev: true
optional: true
- /esbuild-linux-s390x/0.14.25:
- resolution: {integrity: sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==}
+ /esbuild-linux-s390x/0.14.31:
+ resolution: {integrity: sha512-GIwV9mY3koYja9MCSkKLk1P7rj+MkPV0UsGsZ575hEcIBrXeKN9jBi6X/bxDDPEN/SUAH35cJhBNrZU4x9lEfg==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
@@ -1785,8 +1785,8 @@ packages:
dev: true
optional: true
- /esbuild-netbsd-64/0.14.25:
- resolution: {integrity: sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==}
+ /esbuild-netbsd-64/0.14.31:
+ resolution: {integrity: sha512-bJ+pyLvKQm+Obp5k7/Wk8e9Gdkls56F1aiI3uptoIfOIUqsZImH7pDyTrSufwqsFp62kO9LRuwXnjDwQtPyhFQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
@@ -1797,11 +1797,11 @@ packages:
/esbuild-node-loader/0.6.5:
resolution: {integrity: sha512-uPP+dllWm38cFvDysdocutN3lfe5pTIbddAHp1ENyLzpHYqE2r+3Wo+pfg9X3p8DFWwzIisft5YkeBIthIcixw==}
dependencies:
- esbuild: 0.14.25
+ esbuild: 0.14.31
dev: true
- /esbuild-openbsd-64/0.14.25:
- resolution: {integrity: sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==}
+ /esbuild-openbsd-64/0.14.31:
+ resolution: {integrity: sha512-NRAAPPca05H9j9Xab0kVXK0V6/pyZGGy8d2Y8KS0BMwWEydlD4KCJDmH8/7bWCKYLRGOOCE9/GPBJyPWHFW3sg==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
@@ -1809,16 +1809,16 @@ packages:
dev: true
optional: true
- /esbuild-register/3.3.2_esbuild@0.14.25:
+ /esbuild-register/3.3.2_esbuild@0.14.31:
resolution: {integrity: sha512-jceAtTO6zxPmCfSD5cBb3rgIK1vmuqCKYwgylHiS1BF4pq0jJiJb4K2QMuqF4BEw7XDBRatYzip0upyTzfkgsQ==}
peerDependencies:
esbuild: '>=0.12 <1'
dependencies:
- esbuild: 0.14.25
+ esbuild: 0.14.31
dev: true
- /esbuild-sunos-64/0.14.25:
- resolution: {integrity: sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==}
+ /esbuild-sunos-64/0.14.31:
+ resolution: {integrity: sha512-9uA+V8w9Eehu4ldb95lPWdgCMcMO5HH6pXmfkk5usn3JsSZxKdLKsXB4hYgP80wscZvVYXJl2G+KNxsUTfPhZw==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
@@ -1826,8 +1826,8 @@ packages:
dev: true
optional: true
- /esbuild-windows-32/0.14.25:
- resolution: {integrity: sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==}
+ /esbuild-windows-32/0.14.31:
+ resolution: {integrity: sha512-VGdncQTqoxD9q3v/dk0Yugbmx2FzOkcs0OemBYc1X9KXOLQYH0uQbLJIckZdZOC3J+JKSExbYFrzYCOwWPuNyA==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
@@ -1835,8 +1835,8 @@ packages:
dev: true
optional: true
- /esbuild-windows-64/0.14.25:
- resolution: {integrity: sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==}
+ /esbuild-windows-64/0.14.31:
+ resolution: {integrity: sha512-v/2ye5zBqpmCzi3bLCagStbNQlnOsY7WtMrD2Q0xZxeSIXONxji15KYtVee5o7nw4lXWbQSS1BL8G6BBMvtq4A==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
@@ -1844,8 +1844,8 @@ packages:
dev: true
optional: true
- /esbuild-windows-arm64/0.14.25:
- resolution: {integrity: sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==}
+ /esbuild-windows-arm64/0.14.31:
+ resolution: {integrity: sha512-RXeU42FJoG1sriNHg73h4S+5B7L/gw+8T7U9u8IWqSSEbY6fZvBh4uofugiU1szUDqqP00GHwZ09WgYe3lGZiw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
@@ -1853,32 +1853,32 @@ packages:
dev: true
optional: true
- /esbuild/0.14.25:
- resolution: {integrity: sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==}
+ /esbuild/0.14.31:
+ resolution: {integrity: sha512-QA0fUM13+JZzcvg1bdrhi7wo8Lr5IRHA9ypNn2znqxGqb66dSK6pAh01TjyBOhzZGazPQJZ1K26VrCAQJ715qA==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
- esbuild-android-64: 0.14.25
- esbuild-android-arm64: 0.14.25
- esbuild-darwin-64: 0.14.25
- esbuild-darwin-arm64: 0.14.25
- esbuild-freebsd-64: 0.14.25
- esbuild-freebsd-arm64: 0.14.25
- esbuild-linux-32: 0.14.25
- esbuild-linux-64: 0.14.25
- esbuild-linux-arm: 0.14.25
- esbuild-linux-arm64: 0.14.25
- esbuild-linux-mips64le: 0.14.25
- esbuild-linux-ppc64le: 0.14.25
- esbuild-linux-riscv64: 0.14.25
- esbuild-linux-s390x: 0.14.25
- esbuild-netbsd-64: 0.14.25
- esbuild-openbsd-64: 0.14.25
- esbuild-sunos-64: 0.14.25
- esbuild-windows-32: 0.14.25
- esbuild-windows-64: 0.14.25
- esbuild-windows-arm64: 0.14.25
+ esbuild-android-64: 0.14.31
+ esbuild-android-arm64: 0.14.31
+ esbuild-darwin-64: 0.14.31
+ esbuild-darwin-arm64: 0.14.31
+ esbuild-freebsd-64: 0.14.31
+ esbuild-freebsd-arm64: 0.14.31
+ esbuild-linux-32: 0.14.31
+ esbuild-linux-64: 0.14.31
+ esbuild-linux-arm: 0.14.31
+ esbuild-linux-arm64: 0.14.31
+ esbuild-linux-mips64le: 0.14.31
+ esbuild-linux-ppc64le: 0.14.31
+ esbuild-linux-riscv64: 0.14.31
+ esbuild-linux-s390x: 0.14.31
+ esbuild-netbsd-64: 0.14.31
+ esbuild-openbsd-64: 0.14.31
+ esbuild-sunos-64: 0.14.31
+ esbuild-windows-32: 0.14.31
+ esbuild-windows-64: 0.14.31
+ esbuild-windows-arm64: 0.14.31
dev: true
/escalade/3.1.1:
@@ -1896,45 +1896,45 @@ packages:
engines: {node: '>=10'}
dev: true
- /eslint-config-prettier/8.5.0_eslint@8.11.0:
+ /eslint-config-prettier/8.5.0_eslint@8.12.0:
resolution: {integrity: sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==}
hasBin: true
peerDependencies:
eslint: '>=7.0.0'
dependencies:
- eslint: 8.11.0
+ eslint: 8.12.0
dev: true
- /eslint-define-config/1.2.5:
- resolution: {integrity: sha512-WVvtYiovaQTUVHZmB5xnP6HyBktJIOpL4XWFPaSgA/gKFndnD4o5yRRv2EZXqQAU1kdwD/ZHKGrHJ2C6gdSgCA==}
- engines: {node: '>= 16.9.0', npm: '>= 7.0.0', pnpm: '>= 6.30.1'}
+ /eslint-define-config/1.3.0:
+ resolution: {integrity: sha512-sFbHUnaXdJfG74c0EfFjXajjM3ugDVOMteKBnddCHQP5eas6p3nmS7PbSVhyZ8Y9DaNNtFbzlovdGmVdTwrHcw==}
+ engines: {node: '>= 16.9.0', npm: '>= 7.0.0', pnpm: '>= 6.32.2'}
dev: true
- /eslint-gitignore/0.1.0_eslint@8.11.0:
+ /eslint-gitignore/0.1.0_eslint@8.12.0:
resolution: {integrity: sha512-VFvY5Wyjuz5xXDC/NeONHzsh4YQNok2Gzg4SftAAuhkbrdHv5CChjfiFyLKhRlgOdCJr5kBquaLXHtuDBTW2/Q==}
engines: {node: ^10.12.0 || >=12.0.0}
peerDependencies:
eslint: '>=6.7.0'
dependencies:
array.prototype.flatmap: 1.2.5
- debug: 4.3.3
- eslint: 8.11.0
+ debug: 4.3.4
+ eslint: 8.12.0
fast-glob: 3.2.11
transitivePeerDependencies:
- supports-color
dev: true
- /eslint-plugin-jsdoc/38.0.2_eslint@8.11.0:
- resolution: {integrity: sha512-ln9eUYcok3zTX1MG6RE37SbsF81f1Lopy9ucYoIXbYOYQJqmFcAdnzlUMCaMhzR6v5SeKugchtOYXh7Oy+cZlA==}
+ /eslint-plugin-jsdoc/38.1.6_eslint@8.12.0:
+ resolution: {integrity: sha512-n4s95oYlg0L43Bs8C0dkzIldxYf8pLCutC/tCbjIdF7VDiobuzPI+HZn9Q0BvgOvgPNgh5n7CSStql25HUG4Tw==}
engines: {node: ^12 || ^14 || ^16 || ^17}
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
dependencies:
- '@es-joy/jsdoccomment': 0.20.1
- comment-parser: 1.3.0
- debug: 4.3.3
+ '@es-joy/jsdoccomment': 0.22.1
+ comment-parser: 1.3.1
+ debug: 4.3.4
escape-string-regexp: 4.0.0
- eslint: 8.11.0
+ eslint: 8.12.0
esquery: 1.4.0
regextras: 0.8.0
semver: 7.3.5
@@ -1943,7 +1943,7 @@ packages:
- supports-color
dev: true
- /eslint-plugin-prettier/4.0.0_c9d5adccfd1d43a8805a302169f6a967:
+ /eslint-plugin-prettier/4.0.0_f2c91d0f54113167d2bd9214a5ab5a36:
resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==}
engines: {node: '>=6.0.0'}
peerDependencies:
@@ -1954,9 +1954,9 @@ packages:
eslint-config-prettier:
optional: true
dependencies:
- eslint: 8.11.0
- eslint-config-prettier: 8.5.0_eslint@8.11.0
- prettier: 2.5.1
+ eslint: 8.12.0
+ eslint-config-prettier: 8.5.0_eslint@8.12.0
+ prettier: 2.6.2
prettier-linter-helpers: 1.0.0
dev: true
@@ -1976,13 +1976,13 @@ packages:
estraverse: 5.3.0
dev: true
- /eslint-utils/3.0.0_eslint@8.11.0:
+ /eslint-utils/3.0.0_eslint@8.12.0:
resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==}
engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0}
peerDependencies:
eslint: '>=5'
dependencies:
- eslint: 8.11.0
+ eslint: 8.12.0
eslint-visitor-keys: 2.1.0
dev: true
@@ -1996,8 +1996,8 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
- /eslint/8.11.0:
- resolution: {integrity: sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==}
+ /eslint/8.12.0:
+ resolution: {integrity: sha512-it1oBL9alZg1S8UycLm5YDMAkIhtH6FtAzuZs6YvoGVldWjbS08BkAdb/ymP9LlAyq8koANu32U7Ib/w+UNh8Q==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
hasBin: true
dependencies:
@@ -2006,11 +2006,11 @@ packages:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.3
+ debug: 4.3.4
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.1.1
- eslint-utils: 3.0.0_eslint@8.11.0
+ eslint-utils: 3.0.0_eslint@8.12.0
eslint-visitor-keys: 3.3.0
espree: 9.3.1
esquery: 1.4.0
@@ -2019,7 +2019,7 @@ packages:
file-entry-cache: 6.0.1
functional-red-black-tree: 1.0.1
glob-parent: 6.0.2
- globals: 13.12.1
+ globals: 13.13.0
ignore: 5.2.0
import-fresh: 3.3.0
imurmurhash: 0.1.4
@@ -2045,9 +2045,9 @@ packages:
hasBin: true
dependencies:
cross-spawn: 7.0.3
- esbuild: 0.14.25
+ esbuild: 0.14.31
esbuild-node-loader: 0.6.5
- esbuild-register: 3.3.2_esbuild@0.14.25
+ esbuild-register: 3.3.2_esbuild@0.14.31
import-meta-resolve: 1.1.1
dev: true
@@ -2143,7 +2143,7 @@ packages:
engines: {node: '>= 10.17.0'}
hasBin: true
dependencies:
- debug: 4.3.3_supports-color@8.1.1
+ debug: 4.3.4_supports-color@8.1.1
get-stream: 5.2.0
yauzl: 2.10.0
optionalDependencies:
@@ -2173,7 +2173,7 @@ packages:
'@nodelib/fs.walk': 1.2.8
glob-parent: 5.1.2
merge2: 1.4.1
- micromatch: 4.0.4
+ micromatch: 4.0.5
dev: true
/fast-json-stable-stringify/2.1.0:
@@ -2277,7 +2277,7 @@ packages:
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
- mime-types: 2.1.34
+ mime-types: 2.1.35
dev: true
/fs-access/1.0.1:
@@ -2444,8 +2444,8 @@ packages:
ini: 2.0.0
dev: true
- /globals/13.12.1:
- resolution: {integrity: sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==}
+ /globals/13.13.0:
+ resolution: {integrity: sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==}
engines: {node: '>=8'}
dependencies:
type-fest: 0.20.2
@@ -2472,12 +2472,12 @@ packages:
engines: {node: '>=0.4.7'}
hasBin: true
dependencies:
- minimist: 1.2.5
+ minimist: 1.2.6
neo-async: 2.6.2
source-map: 0.6.1
wordwrap: 1.0.0
optionalDependencies:
- uglify-js: 3.15.2
+ uglify-js: 3.15.3
dev: true
/hard-rejection/2.1.0:
@@ -2537,7 +2537,7 @@ packages:
resolution: {integrity: sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==}
dependencies:
domelementtype: 2.2.0
- domhandler: 4.3.0
+ domhandler: 4.3.1
domutils: 2.8.0
entities: 2.2.0
dev: true
@@ -2581,7 +2581,7 @@ packages:
/import-meta-resolve/1.1.1:
resolution: {integrity: sha512-JiTuIvVyPaUg11eTrNDx5bgQ/yMKMZffc7YSjvQeSMXy58DO2SQ8BtAf3xteZvmzvjYh14wnqNjL8XVeDy2o9A==}
dependencies:
- builtins: 4.0.0
+ builtins: 4.1.0
dev: true
/imurmurhash/0.1.4:
@@ -2701,8 +2701,8 @@ packages:
engines: {node: '>= 0.4'}
dev: true
- /is-number-object/1.0.6:
- resolution: {integrity: sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==}
+ /is-number-object/1.0.7:
+ resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==}
engines: {node: '>= 0.4'}
dependencies:
has-tostringtag: 1.0.0
@@ -2741,8 +2741,10 @@ packages:
has-tostringtag: 1.0.0
dev: true
- /is-shared-array-buffer/1.0.1:
- resolution: {integrity: sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==}
+ /is-shared-array-buffer/1.0.2:
+ resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==}
+ dependencies:
+ call-bind: 1.0.2
dev: true
/is-stream/2.0.1:
@@ -2835,8 +2837,8 @@ packages:
resolution: {integrity: sha1-peZUwuWi3rXyAdls77yoDA7y9RM=}
dev: true
- /jsdoc-type-pratt-parser/2.2.3:
- resolution: {integrity: sha512-QPyxq62Q8veBSDtDrWmqaEPjSCeknUV9dH/OAGt3q9an8qC8UQDqitQiw1NvoMskIESpoRZ6qzt4H3rlK0xo8A==}
+ /jsdoc-type-pratt-parser/2.2.5:
+ resolution: {integrity: sha512-2a6eRxSxp1BW040hFvaJxhsCMI9lT8QB8t14t+NY5tC5rckIR0U9cr2tjOeaFirmEOy6MHvmJnY7zTBHq431Lw==}
engines: {node: '>=12.0.0'}
dev: true
@@ -2918,23 +2920,24 @@ packages:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
dev: true
- /lint-staged/12.3.5:
- resolution: {integrity: sha512-oOH36RUs1It7b9U/C7Nl/a0sLfoIBcMB8ramiB3nuJ6brBqzsWiUAFSR5DQ3yyP/OR7XKMpijtgKl2DV1lQ3lA==}
+ /lint-staged/12.3.7:
+ resolution: {integrity: sha512-/S4D726e2GIsDVWIk1XGvheCaDm1SJRQp8efamZFWJxQMVEbOwSysp7xb49Oo73KYCdy97mIWinhlxcoNqIfIQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
hasBin: true
dependencies:
cli-truncate: 3.1.0
colorette: 2.0.16
commander: 8.3.0
- debug: 4.3.3_supports-color@9.2.1
+ debug: 4.3.4_supports-color@9.2.2
execa: 5.1.1
lilconfig: 2.0.4
- listr2: 4.0.4
- micromatch: 4.0.4
+ listr2: 4.0.5
+ micromatch: 4.0.5
normalize-path: 3.0.0
object-inspect: 1.12.0
+ pidtree: 0.5.0
string-argv: 0.3.1
- supports-color: 9.2.1
+ supports-color: 9.2.2
yaml: 1.10.2
transitivePeerDependencies:
- enquirer
@@ -2955,13 +2958,13 @@ packages:
log-update: 4.0.0
p-map: 4.0.0
rfdc: 1.3.0
- rxjs: 7.5.4
+ rxjs: 7.5.5
through: 2.3.8
wrap-ansi: 7.0.0
dev: true
- /listr2/4.0.4:
- resolution: {integrity: sha512-vJOm5KD6uZXjSsrwajr+mNacIjf87gWvlBEltPWLbTkslUscWAzquyK4xfe9Zd4RDgO5nnwFyV06FC+uVR+5mg==}
+ /listr2/4.0.5:
+ resolution: {integrity: sha512-juGHV1doQdpNT3GSTs9IUN43QJb7KHdF9uqg7Vufs/tG9VTzpFphqF4pm/ICdAABGQxsyNn9CiYA3StkI6jpwA==}
engines: {node: '>=12'}
peerDependencies:
enquirer: '>= 2.3.0 < 3'
@@ -2974,7 +2977,7 @@ packages:
log-update: 4.0.0
p-map: 4.0.0
rfdc: 1.3.0
- rxjs: 7.5.4
+ rxjs: 7.5.5
through: 2.3.8
wrap-ansi: 7.0.0
dev: true
@@ -3135,24 +3138,24 @@ packages:
engines: {node: '>= 8'}
dev: true
- /micromatch/4.0.4:
- resolution: {integrity: sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==}
+ /micromatch/4.0.5:
+ resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==}
engines: {node: '>=8.6'}
dependencies:
braces: 3.0.2
picomatch: 2.3.1
dev: true
- /mime-db/1.51.0:
- resolution: {integrity: sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==}
+ /mime-db/1.52.0:
+ resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: true
- /mime-types/2.1.34:
- resolution: {integrity: sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==}
+ /mime-types/2.1.35:
+ resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
- mime-db: 1.51.0
+ mime-db: 1.52.0
dev: true
/mimic-fn/2.1.0:
@@ -3187,8 +3190,8 @@ packages:
kind-of: 6.0.3
dev: true
- /minimist/1.2.5:
- resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
+ /minimist/1.2.6:
+ resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==}
dev: true
/modify-values/1.0.1:
@@ -3209,8 +3212,8 @@ packages:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: true
- /nanoid/3.3.1:
- resolution: {integrity: sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==}
+ /nanoid/3.3.2:
+ resolution: {integrity: sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
@@ -3490,6 +3493,12 @@ packages:
hasBin: true
dev: true
+ /pidtree/0.5.0:
+ resolution: {integrity: sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA==}
+ engines: {node: '>=0.10'}
+ hasBin: true
+ dev: true
+
/pify/2.3.0:
resolution: {integrity: sha1-7RQaasBDqEnqWISY59yosVMw6Qw=}
engines: {node: '>=0.10.0'}
@@ -3500,17 +3509,17 @@ packages:
engines: {node: '>=4'}
dev: true
- /postcss/8.4.7:
- resolution: {integrity: sha512-L9Ye3r6hkkCeOETQX6iOaWZgjp3LL6Lpqm6EtgbKrgqGGteRMNb9vzBfRL96YOSu8o7x3MfIH9Mo5cPJFGrW6A==}
+ /postcss/8.4.12:
+ resolution: {integrity: sha512-lg6eITwYe9v6Hr5CncVbK70SoioNQIq81nsaG86ev5hAidQvmOeETBqs7jm43K2F5/Ley3ytDtriImV6TpNiSg==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
- nanoid: 3.3.1
+ nanoid: 3.3.2
picocolors: 1.0.0
source-map-js: 1.0.2
dev: true
- /preact/10.6.6:
- resolution: {integrity: sha512-dgxpTFV2vs4vizwKohYKkk7g7rmp1wOOcfd4Tz3IB3Wi+ivZzsn/SpeKJhRENSE+n8sUfsAl4S3HiCVT923ABw==}
+ /preact/10.7.0:
+ resolution: {integrity: sha512-9MEURwzNMKpAil/t6+wabDIJI6oG6GnwypYxiJDvQnW+fHDTt51PYuLZ1QUM31hFr7sDaj9qTaShAF9VIxuxGQ==}
dev: true
/prelude-ls/1.2.1:
@@ -3525,18 +3534,18 @@ packages:
fast-diff: 1.2.0
dev: true
- /prettier-plugin-organize-imports/2.3.4_prettier@2.5.1+typescript@4.6.2:
+ /prettier-plugin-organize-imports/2.3.4_prettier@2.6.2+typescript@4.6.3:
resolution: {integrity: sha512-R8o23sf5iVL/U71h9SFUdhdOEPsi3nm42FD/oDYIZ2PQa4TNWWuWecxln6jlIQzpZTDMUeO1NicJP6lLn2TtRw==}
peerDependencies:
prettier: '>=2.0'
typescript: '>=2.9'
dependencies:
- prettier: 2.5.1
- typescript: 4.6.2
+ prettier: 2.6.2
+ typescript: 4.6.3
dev: true
- /prettier/2.5.1:
- resolution: {integrity: sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==}
+ /prettier/2.6.2:
+ resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
engines: {node: '>=10.13.0'}
hasBin: true
dev: true
@@ -3718,8 +3727,8 @@ packages:
glob: 7.2.0
dev: true
- /rollup/2.69.0:
- resolution: {integrity: sha512-kjER91tHyek8gAkuz7+558vSnTQ+pITEok1P0aNOS45ZXyngaqPsXJmSel4QPQnJo7EJMjXUU1/GErWkWiKORg==}
+ /rollup/2.70.1:
+ resolution: {integrity: sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA==}
engines: {node: '>=10.0.0'}
hasBin: true
optionalDependencies:
@@ -3732,8 +3741,8 @@ packages:
queue-microtask: 1.2.3
dev: true
- /rxjs/7.5.4:
- resolution: {integrity: sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==}
+ /rxjs/7.5.5:
+ resolution: {integrity: sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==}
dependencies:
tslib: 2.3.1
dev: true
@@ -3758,7 +3767,7 @@ packages:
htmlparser2: 6.1.0
is-plain-object: 5.0.0
parse-srcset: 1.0.2
- postcss: 8.4.7
+ postcss: 8.4.12
dev: true
/semver/5.7.1:
@@ -3993,7 +4002,7 @@ packages:
dependencies:
call-bind: 1.0.2
define-properties: 1.1.3
- es-abstract: 1.19.1
+ es-abstract: 1.19.2
dev: true
/string.prototype.trimend/1.0.4:
@@ -4083,8 +4092,8 @@ packages:
has-flag: 4.0.0
dev: true
- /supports-color/9.2.1:
- resolution: {integrity: sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ==}
+ /supports-color/9.2.2:
+ resolution: {integrity: sha512-XC6g/Kgux+rJXmwokjm9ECpD6k/smUoS5LKlUCcsYr4IY3rW0XyAympon2RmxGrlnZURMpg5T18gWDP9CsHXFA==}
engines: {node: '>=12'}
dev: true
@@ -4150,8 +4159,8 @@ packages:
engines: {node: '>=14.0.0'}
dev: true
- /tinyspy/0.3.0:
- resolution: {integrity: sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==}
+ /tinyspy/0.3.1:
+ resolution: {integrity: sha512-XXD1NYn5HciffxgxlHmOzq45tTNKRtPHss5go1ZAQmX9LLBIszXLG+NEpnD0shS2F2OMcQ9VSk7IswEeViCrbw==}
engines: {node: '>=14.0.0'}
dev: true
@@ -4195,14 +4204,14 @@ packages:
resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==}
dev: true
- /tsutils/3.21.0_typescript@4.6.2:
+ /tsutils/3.21.0_typescript@4.6.3:
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
dependencies:
tslib: 1.14.1
- typescript: 4.6.2
+ typescript: 4.6.3
dev: true
/tunnel-agent/0.6.0:
@@ -4261,10 +4270,10 @@ packages:
peerDependencies:
typedoc: 0.22.x
dependencies:
- typedoc: 0.22.13_typescript@4.6.2
+ typedoc: 0.22.13_typescript@4.6.3
dev: true
- /typedoc/0.22.13_typescript@4.6.2:
+ /typedoc/0.22.13_typescript@4.6.3:
resolution: {integrity: sha512-NHNI7Dr6JHa/I3+c62gdRNXBIyX7P33O9TafGLd07ur3MqzcKgwTvpg18EtvCLHJyfeSthAtCLpM7WkStUmDuQ==}
engines: {node: '>= 12.10.0'}
hasBin: true
@@ -4276,17 +4285,17 @@ packages:
marked: 4.0.12
minimatch: 5.0.1
shiki: 0.10.1
- typescript: 4.6.2
+ typescript: 4.6.3
dev: true
- /typescript/4.6.2:
- resolution: {integrity: sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==}
+ /typescript/4.6.3:
+ resolution: {integrity: sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==}
engines: {node: '>=4.2.0'}
hasBin: true
dev: true
- /uglify-js/3.15.2:
- resolution: {integrity: sha512-peeoTk3hSwYdoc9nrdiEJk+gx1ALCtTjdYuKSXMTDqq7n1W7dHPqWDdSi+BPL0ni2YMeHD7hKUSdbj3TZauY2A==}
+ /uglify-js/3.15.3:
+ resolution: {integrity: sha512-6iCVm2omGJbsu3JWac+p6kUiOpg3wFO2f8lIXjfEb8RrmLjzog1wTPMmwKB7swfzzqxj9YM+sGUM++u1qN4qJg==}
engines: {node: '>=0.8.0'}
hasBin: true
requiresBuild: true
@@ -4367,8 +4376,8 @@ packages:
extsprintf: 1.3.0
dev: true
- /vite/2.8.6:
- resolution: {integrity: sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==}
+ /vite/2.9.1:
+ resolution: {integrity: sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==}
engines: {node: '>=12.2.0'}
hasBin: true
peerDependencies:
@@ -4383,10 +4392,10 @@ packages:
stylus:
optional: true
dependencies:
- esbuild: 0.14.25
- postcss: 8.4.7
+ esbuild: 0.14.31
+ postcss: 8.4.12
resolve: 1.22.0
- rollup: 2.69.0
+ rollup: 2.70.1
optionalDependencies:
fsevents: 2.3.2
dev: true
@@ -4398,9 +4407,9 @@ packages:
dependencies:
'@docsearch/css': 3.0.0
'@docsearch/js': 3.0.0
- '@vitejs/plugin-vue': 2.2.4_vite@2.8.6+vue@3.2.31
+ '@vitejs/plugin-vue': 2.3.1_vite@2.9.1+vue@3.2.31
prismjs: 1.27.0
- vite: 2.8.6
+ vite: 2.9.1
vue: 3.2.31
transitivePeerDependencies:
- '@algolia/client-search'
@@ -4412,9 +4421,9 @@ packages:
- stylus
dev: true
- /vitest/0.6.0_@vitest+ui@0.6.0+c8@7.11.0:
- resolution: {integrity: sha512-FuIkLHCQxz6rO35MQROUtVdwcBaYnt198YpPGIrJXmuNHGolfPbrZIiwpD7bek0OiETxuphK3+KR5oJ5Qi1g5A==}
- engines: {node: '>=14.14.0'}
+ /vitest/0.8.4_@vitest+ui@0.8.4+c8@7.11.0:
+ resolution: {integrity: sha512-1OoAG1+VYkzp4WLCVQFRJX/OKk70rsMIM5H23crfc1wSEnJvHlxgQBS1HPpV/VYmjC8bIInKWhnB4Gaw32MnyQ==}
+ engines: {node: '>=v14.16.0'}
hasBin: true
peerDependencies:
'@vitest/ui': '*'
@@ -4433,13 +4442,13 @@ packages:
dependencies:
'@types/chai': 4.3.0
'@types/chai-subset': 1.3.3
- '@vitest/ui': 0.6.0
+ '@vitest/ui': 0.8.4
c8: 7.11.0
chai: 4.3.6
local-pkg: 0.4.1
tinypool: 0.1.2
- tinyspy: 0.3.0
- vite: 2.8.6
+ tinyspy: 0.3.1
+ vite: 2.9.1
transitivePeerDependencies:
- less
- sass
@@ -4469,7 +4478,7 @@ packages:
dependencies:
is-bigint: 1.0.4
is-boolean-object: 1.1.2
- is-number-object: 1.0.6
+ is-number-object: 1.0.7
is-string: 1.0.7
is-symbol: 1.0.4
dev: true
diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts
index cb4ed2a4e12..4ac4fbf9776 100644
--- a/scripts/apidoc.ts
+++ b/scripts/apidoc.ts
@@ -3,6 +3,11 @@ import * as TypeDoc from 'typedoc';
import { writeApiPagesIndex } from './apidoc/apiDocsWriter';
import { processDirectMethods } from './apidoc/directMethods';
import { processModuleMethods } from './apidoc/moduleMethods';
+import {
+ DefaultParameterAwareSerializer,
+ parameterDefaultReader,
+ patchProjectParameterDefaults,
+} from './apidoc/parameterDefaults';
import type { PageIndex } from './apidoc/utils';
import { pathOutputDir } from './apidoc/utils';
@@ -15,6 +20,14 @@ async function build(): Promise {
// If you want TypeDoc to load typedoc.json files
//app.options.addReader(new TypeDoc.TypeDocReader());
+ // Read parameter defaults
+ app.converter.on(
+ TypeDoc.Converter.EVENT_CREATE_DECLARATION,
+ parameterDefaultReader
+ );
+ // Add to debug json output
+ app.serializer.addSerializer(new DefaultParameterAwareSerializer(undefined));
+
app.bootstrap({
entryPoints: ['src/index.ts'],
pretty: true,
@@ -31,6 +44,8 @@ async function build(): Promise {
await app.generateJson(project, pathOutputJson);
console.log(pathOutputDir);
+ patchProjectParameterDefaults(project);
+
const modulesPages: PageIndex = [];
modulesPages.push({ text: 'Localization', link: '/api/localization.html' });
modulesPages.push(...processModuleMethods(project));
diff --git a/scripts/apidoc/apiDocsWriter.ts b/scripts/apidoc/apiDocsWriter.ts
index 1282ad4c96a..5d37585d5b4 100644
--- a/scripts/apidoc/apiDocsWriter.ts
+++ b/scripts/apidoc/apiDocsWriter.ts
@@ -7,7 +7,7 @@ import type { Method } from '../../docs/.vitepress/components/api-docs/method';
import type { PageIndex } from './utils';
import { pathDocsDir, pathOutputDir } from './utils';
-const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.mjs');
+const pathDocsApiPages = resolve(pathDocsDir, '.vitepress', 'api-pages.ts');
const scriptCommand = 'pnpm run generate:api-docs';
@@ -133,8 +133,8 @@ export const ${lowerModuleName}: Method[] = ${JSON.stringify(
* @param pages The pages to write into the index.
*/
export function writeApiPagesIndex(pages: PageIndex): void {
- // Write api-pages.mjs
- console.log('Updating api-pages.mjs');
+ // Write api-pages.ts
+ console.log('Updating api-pages.ts');
pages.sort((a, b) => a.text.localeCompare(b.text));
let apiPagesContent = `
// This file is automatically generated.
diff --git a/scripts/apidoc/parameterDefaults.ts b/scripts/apidoc/parameterDefaults.ts
new file mode 100644
index 00000000000..5e10202c098
--- /dev/null
+++ b/scripts/apidoc/parameterDefaults.ts
@@ -0,0 +1,130 @@
+import type {
+ Context,
+ DeclarationReflection,
+ EventCallback,
+ JSONOutput,
+ ProjectReflection,
+ SignatureReflection,
+} from 'typedoc';
+import {
+ Reflection,
+ ReflectionKind,
+ SerializerComponent,
+ TypeScript,
+} from 'typedoc';
+
+const reflectionKindFunctionOrMethod =
+ ReflectionKind.Function | ReflectionKind.Method;
+
+interface ParameterDefaultsAware extends Reflection {
+ implementationDefaultParameters: string[];
+}
+
+/**
+ * TypeDoc EventCallback for EVENT_CREATE_DECLARATION events that reads the default parameters from the implementation.
+ */
+export const parameterDefaultReader: EventCallback = (
+ context: Context,
+ reflection: Reflection
+): void => {
+ const symbol = context.project.getSymbolFromReflection(reflection);
+ if (!symbol) return;
+
+ if (
+ reflection.kindOf(reflectionKindFunctionOrMethod) &&
+ symbol.declarations?.length
+ ) {
+ const lastDeclaration = symbol.declarations[symbol.declarations.length - 1];
+ if (TypeScript.isFunctionLike(lastDeclaration)) {
+ (reflection as ParameterDefaultsAware).implementationDefaultParameters =
+ lastDeclaration.parameters.map((param) =>
+ cleanParameterDefault(param.initializer?.getText())
+ );
+ }
+ }
+};
+
+/**
+ * Removes compile expressions that don't add any value for readers.
+ *
+ * @param value The default value to clean.
+ * @returns The cleaned default value.
+ */
+function cleanParameterDefault(value?: string): string {
+ if (value == null) {
+ return undefined;
+ }
+ // Strip type casts: "'foobar' as unknown as T" => "'foobar'"
+ return value.replace(/ as unknown as [A-Za-z<>]+/, '');
+}
+
+/**
+ * Serializer that adds the `implementationDefaultParameters` to the JSON output.
+ */
+export class DefaultParameterAwareSerializer extends SerializerComponent {
+ serializeGroup(instance: unknown): boolean {
+ return instance instanceof Reflection;
+ }
+
+ supports(): boolean {
+ return true;
+ }
+
+ toObject(item: Reflection, obj?: object): Partial {
+ (obj as ParameterDefaultsAware).implementationDefaultParameters = (
+ item as ParameterDefaultsAware
+ ).implementationDefaultParameters;
+ return obj;
+ }
+}
+
+/**
+ * Replaces all methods' last signature's parameter's default value with the default value read from the implementation.
+ *
+ * @param project The project to patch.
+ */
+export function patchProjectParameterDefaults(
+ project: ProjectReflection
+): void {
+ const functionOrMethods = project.getReflectionsByKind(
+ reflectionKindFunctionOrMethod
+ ) as DeclarationReflection[];
+ for (const functionOrMethod of functionOrMethods) {
+ patchMethodParameterDefaults(functionOrMethod);
+ }
+}
+
+/**
+ * Replaces the last signature's parameter's default value with the default value read from the implementation.
+ *
+ * @param method The method to patch.
+ */
+function patchMethodParameterDefaults(method: DeclarationReflection): void {
+ const signatures = method.signatures;
+ const signature = signatures[signatures.length - 1];
+ const parameterDefaults = (method as unknown as ParameterDefaultsAware)
+ .implementationDefaultParameters;
+ if (parameterDefaults) {
+ patchSignatureParameterDefaults(signature, parameterDefaults);
+ }
+}
+
+/**
+ * Replaces the given signature's parameter's default value with the given default values.
+ *
+ * @param signature The signature to patch.
+ * @param parameterDefaults The defaults to add.
+ */
+function patchSignatureParameterDefaults(
+ signature: SignatureReflection,
+ parameterDefaults: string[]
+): void {
+ const signatureParameters = signature.parameters;
+ if (signatureParameters.length !== parameterDefaults.length) {
+ throw new Error('Unexpected parameter length mismatch');
+ }
+ signatureParameters.forEach(
+ (param, index) =>
+ (param.defaultValue = parameterDefaults[index] || param.defaultValue)
+ );
+}
diff --git a/scripts/apidoc/signature.ts b/scripts/apidoc/signature.ts
index 287fc737fc3..31674c834a0 100644
--- a/scripts/apidoc/signature.ts
+++ b/scripts/apidoc/signature.ts
@@ -1,10 +1,12 @@
import sanitizeHtml from 'sanitize-html';
import type {
Comment,
+ DeclarationReflection,
ParameterReflection,
Reflection,
SignatureReflection,
SomeType,
+ Type,
} from 'typedoc';
import { ReflectionFlag, ReflectionKind } from 'typedoc';
import { createMarkdownRenderer } from 'vitepress';
@@ -78,7 +80,8 @@ export function analyzeSignature(
for (const parameter of typeParameters) {
signatureTypeParameters.push(parameter.name);
parameters.push({
- name: parameter.name,
+ name: `<${parameter.name}>`,
+ type: parameter.type ? typeToText(parameter.type) : undefined,
description: mdToHtml(toBlock(parameter.comment)),
});
}
@@ -145,7 +148,7 @@ export function analyzeSignature(
title: prettyMethodName,
description: mdToHtml(toBlock(signature.comment)),
parameters: parameters,
- returns: signature.type.toString(),
+ returns: typeToText(signature.type),
examples: mdToHtml('```ts\n' + examples + '```'),
deprecated: signature.comment?.hasTag('deprecated') ?? false,
seeAlsos,
@@ -159,20 +162,20 @@ function analyzeParameter(parameter: ParameterReflection): {
const name = parameter.name;
const declarationName = name + (isOptional(parameter) ? '?' : '');
const type = parameter.type;
- const typeText = type.toString();
- const defaultValue = parameter.defaultValue;
+ const commentDefault = extractDefaultFromComment(parameter.comment);
+ const defaultValue = parameter.defaultValue ?? commentDefault;
let signatureText = '';
if (defaultValue) {
signatureText = ' = ' + defaultValue;
}
- const signature = declarationName + ': ' + typeText + signatureText;
+ const signature = declarationName + ': ' + typeToText(type) + signatureText;
const parameters: MethodParameter[] = [
{
name: declarationName,
- type: typeText,
+ type: typeToText(type, true),
default: defaultValue,
description: mdToHtml(toBlock(parameter.comment)),
},
@@ -194,13 +197,14 @@ function analyzeParameterOptions(
analyzeParameterOptions(name, type)
);
} else if (parameterType.type === 'reflection') {
- const properties = parameterType.declaration.getChildrenByKind(
- ReflectionKind.Property
- );
+ const properties = parameterType.declaration.children ?? [];
return properties.map((property) => ({
name: `${name}.${property.name}${isOptional(property) ? '?' : ''}`,
- type: property.type.toString(),
- description: mdToHtml(toBlock(property.comment)),
+ type: declarationTypeToText(property),
+ default: extractDefaultFromComment(property.comment),
+ description: mdToHtml(
+ toBlock(property.comment ?? property.signatures?.[0].comment)
+ ),
}));
}
@@ -210,3 +214,94 @@ function analyzeParameterOptions(
function isOptional(parameter: Reflection): boolean {
return parameter.flags.hasFlag(ReflectionFlag.Optional);
}
+
+function typeToText(type_: Type, short = false): string {
+ const type = type_ as SomeType;
+ switch (type.type) {
+ case 'array':
+ return `${typeToText(type.elementType, short)}[]`;
+ case 'union':
+ return type.types
+ .map((t) => typeToText(t, short))
+ .sort()
+ .join(' | ');
+ case 'reference':
+ if (!type.typeArguments || !type.typeArguments.length) {
+ return type.name;
+ } else {
+ return `${type.name}<${type.typeArguments
+ .map((t) => typeToText(t, short))
+ .join(', ')}>`;
+ }
+ case 'reflection':
+ return declarationTypeToText(type.declaration, short);
+ case 'indexedAccess':
+ return `${typeToText(type.objectType, short)}[${typeToText(
+ type.indexType,
+ short
+ )}]`;
+ default:
+ return type.toString();
+ }
+}
+
+function declarationTypeToText(
+ declaration: DeclarationReflection,
+ short = false
+): string {
+ switch (declaration.kind) {
+ case ReflectionKind.Method:
+ return signatureTypeToText(declaration.signatures[0]);
+ case ReflectionKind.Property:
+ return typeToText(declaration.type);
+ case ReflectionKind.TypeLiteral:
+ if (declaration.children?.length) {
+ if (short) {
+ // This is too long for the parameter table, thus we abbreviate this.
+ return '{ ... }';
+ }
+ return (
+ '{' +
+ declaration.children
+ .map((c) => `\n${c.name}: ${declarationTypeToText(c)}`)
+ .join()
+ .replace(/\n/g, '\n ') +
+ '\n}'
+ );
+ } else if (declaration.signatures?.length) {
+ return signatureTypeToText(declaration.signatures[0]);
+ } else {
+ return declaration.toString();
+ }
+ default:
+ return declaration.toString();
+ }
+}
+
+function signatureTypeToText(signature: SignatureReflection): string {
+ return `(${signature.parameters
+ .map((p) => `${p.name}: ${typeToText(p.type)}`)
+ .join(', ')}) => ${typeToText(signature.type)}`;
+}
+
+/**
+ * Extracts and removed the parameter default from the comments.
+ *
+ * @param comment The comment to extract the default from.
+ * @returns The extracted default value.
+ */
+function extractDefaultFromComment(comment?: Comment): string {
+ if (!comment) {
+ return;
+ }
+ const text = comment.shortText;
+ if (!text || text.trim() === '') {
+ return;
+ }
+ const result = /(.*)[ \n]Defaults to `([^`]+)`./.exec(text);
+ if (!result) {
+ return;
+ }
+ comment.shortText = result[1];
+ return result[2];
+}
diff --git a/scripts/bundle.ts b/scripts/bundle.ts
index 6d1b7b749ba..29c94102fcc 100644
--- a/scripts/bundle.ts
+++ b/scripts/bundle.ts
@@ -53,4 +53,5 @@ buildSync({
splitting: true,
format: 'esm',
target: 'node12.20',
+ outExtension: { '.js': '.mjs' },
});
diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts
index a402bc1e09c..f4c1f50d50a 100644
--- a/scripts/generateLocales.ts
+++ b/scripts/generateLocales.ts
@@ -1,3 +1,17 @@
+/**
+ * This file contains a script that can be used to update the following files:
+ *
+ * - `src/locale/.ts`
+ * - `src/locales//index.ts`
+ * - `src/locales///index.ts`
+ * - `src/docs/api/localization.md`
+ *
+ * If you wish to edit all/specific locale data files you can do so using the
+ * `updateLocaleFileHook()` method.
+ * Please remember to not commit your temporary update code.
+ *
+ * Run this script using `pnpm run generate:locales`
+ */
import { lstatSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import type { Options } from 'prettier';
@@ -60,7 +74,7 @@ function escapeField(module: string): string {
}
function containsAll(checked?: string[], expected?: string[]): boolean {
- if (typeof expected === 'undefined' || typeof checked === 'undefined') {
+ if (expected == null || checked == null) {
return true;
}
return expected.every((c) => checked.includes(c));
@@ -176,6 +190,7 @@ function generateRecursiveModuleIndexes(
submodules = removeIndexTs(submodules);
for (const submodule of submodules) {
const pathModule = resolve(path, submodule);
+ updateLocaleFile(pathModule);
// Only process sub folders recursively
if (lstatSync(pathModule).isDirectory()) {
let moduleDefinition =
@@ -185,7 +200,7 @@ function generateRecursiveModuleIndexes(
// Overwrite types of src/locales///index.ts for known DEFINITIONS
if (depth === 1) {
moduleFiles = DEFINITIONS[submodule];
- if (typeof moduleFiles === 'undefined') {
+ if (moduleFiles == null) {
moduleDefinition = 'any';
} else {
moduleDefinition = `${submodule.replace(/(^|_)([a-z])/g, (s) =>
@@ -207,6 +222,41 @@ function generateRecursiveModuleIndexes(
}
}
+/**
+ * Intermediate helper function to allow selectively updating locale data files.
+ * Use the `updateLocaleFileHook()` method to temporarily add your custom per file processing/update logic.
+ *
+ * @param filePath The full file path to the file.
+ */
+function updateLocaleFile(filePath: string): void {
+ if (lstatSync(filePath).isFile()) {
+ const pathParts = filePath
+ .substring(pathLocales.length + 1, filePath.length - 3)
+ .split(/[\\\/]/);
+ const locale = pathParts[0];
+ pathParts.splice(0, 1);
+ updateLocaleFileHook(filePath, locale, pathParts);
+ }
+}
+
+/**
+ * Use this hook method to selectively update locale data files (not for index.ts files).
+ * This method is intended to be temporarily overwritten for one-time updates.
+ *
+ * @param filePath The full file path to the file.
+ * @param locale The locale for that file.
+ * @param localePath The locale path parts (after the locale).
+ */
+function updateLocaleFileHook(
+ filePath: string,
+ locale: string,
+ localePath: string[]
+): void {
+ if (filePath === 'never') {
+ console.log(filePath + ' <-> ' + locale + ' @ ' + localePath.join(' -> '));
+ }
+}
+
// Start of actual logic
const locales = readdirSync(pathLocales);
diff --git a/src/address.ts b/src/address.ts
index eff72f2f58c..5c862f5c59f 100644
--- a/src/address.ts
+++ b/src/address.ts
@@ -1,19 +1,79 @@
import type { Faker } from '.';
-import type { Fake } from './fake';
-import type { Helpers } from './helpers';
-let f: Fake['fake'];
+/**
+ * Converts degrees to radians.
+ *
+ * @param degrees Degrees.
+ */
+function degreesToRadians(degrees: number): number {
+ return degrees * (Math.PI / 180.0);
+}
+
+/**
+ * Converts radians to degrees.
+ *
+ * @param radians Radians.
+ */
+function radiansToDegrees(radians: number): number {
+ return radians * (180.0 / Math.PI);
+}
+
+/**
+ * Converts kilometers to miles.
+ *
+ * @param miles Miles.
+ */
+function kilometersToMiles(miles: number): number {
+ return miles * 0.621371;
+}
+
+/**
+ * Calculates coordinates with offset.
+ *
+ * @param coordinate Coordinate.
+ * @param bearing Bearing.
+ * @param distance Distance.
+ * @param isMetric Metric: true, Miles: false.
+ */
+function coordinateWithOffset(
+ coordinate: [number, number],
+ bearing: number,
+ distance: number,
+ isMetric: boolean
+): number[] {
+ const R = 6378.137; // Radius of the Earth (http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html)
+ const d = isMetric ? distance : kilometersToMiles(distance); // Distance in km
+
+ const lat1 = degreesToRadians(coordinate[0]); //Current lat point converted to radians
+ const lon1 = degreesToRadians(coordinate[1]); //Current long point converted to radians
+
+ const lat2 = Math.asin(
+ Math.sin(lat1) * Math.cos(d / R) +
+ Math.cos(lat1) * Math.sin(d / R) * Math.cos(bearing)
+ );
+
+ let lon2 =
+ lon1 +
+ Math.atan2(
+ Math.sin(bearing) * Math.sin(d / R) * Math.cos(lat1),
+ Math.cos(d / R) - Math.sin(lat1) * Math.sin(lat2)
+ );
+
+ // Keep longitude in range [-180, 180]
+ if (lon2 > degreesToRadians(180)) {
+ lon2 = lon2 - degreesToRadians(360);
+ } else if (lon2 < degreesToRadians(-180)) {
+ lon2 = lon2 + degreesToRadians(360);
+ }
+
+ return [radiansToDegrees(lat2), radiansToDegrees(lon2)];
+}
/**
* Module to generate addresses and locations.
*/
export class Address {
- readonly Helpers: Helpers;
-
constructor(private readonly faker: Faker) {
- f = this.faker.fake;
- this.Helpers = this.faker.helpers;
-
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Address.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
@@ -24,8 +84,8 @@ export class Address {
}
/**
- * Generates random zipcode from specified format. If format is not specified, the
- * locale's zip format is used.
+ * Generates random zip code from specified format. If format is not specified,
+ * the locale's zip format is used.
*
* @param format The optional format used to generate the the zip code.
* By default, a random format is used from the locale zip formats.
@@ -39,7 +99,7 @@ export class Address {
*/
zipCode(format?: string): string {
// if zip format is not specified, use the zip format defined for the locale
- if (typeof format === 'undefined') {
+ if (format == null) {
const localeFormat = this.faker.definitions.address.postcode;
if (typeof localeFormat === 'string') {
format = localeFormat;
@@ -47,11 +107,11 @@ export class Address {
format = this.faker.random.arrayElement(localeFormat);
}
}
- return this.Helpers.replaceSymbols(format);
+ return this.faker.helpers.replaceSymbols(format);
}
/**
- * Generates random zipcode from state abbreviation. If state abbreviation is
+ * Generates random zip code from state abbreviation. If state abbreviation is
* not specified, a random zip code is generated according to the locale's zip format.
* Only works for locales with postcode_by_state definition. If a locale does not
* have a postcode_by_state definition, a random zip code is generated according
@@ -63,11 +123,10 @@ export class Address {
* fakerUS.address.zipCodeByState("AK") // '99595'
* fakerUS.address.zipCodeByState("??") // '47683-9880'
*/
- zipCodeByState(state: string): string | number {
- const zipRange = this.faker.definitions.address.postcode_by_state[state];
+ zipCodeByState(state: string): string {
+ const zipRange = this.faker.definitions.address.postcode_by_state?.[state];
if (zipRange) {
- // TODO ST-DDT 2022-02-10: Fix types
- return this.faker.datatype.number(zipRange);
+ return String(this.faker.datatype.number(zipRange));
}
return this.faker.address.zipCode();
}
@@ -108,7 +167,7 @@ export class Address {
format = this.faker.datatype.number(formats.length - 1);
}
- return f(formats[format]);
+ return this.faker.fake(formats[format]);
}
/**
@@ -147,6 +206,20 @@ export class Address {
);
}
+ /**
+ * Generates a random building number.
+ *
+ * @example
+ * faker.address.buildingNumber() // '379'
+ */
+ buildingNumber(): string {
+ const format = this.faker.random.arrayElement(
+ this.faker.definitions.address.building_number
+ );
+
+ return this.faker.helpers.replaceSymbolWithNumber(format);
+ }
+
/**
* Generates a random localized street name.
*
@@ -171,10 +244,6 @@ export class Address {
return result;
}
- //
- // TODO: change all these methods that accept a boolean to instead accept an options hash.
- //
-
/**
* Generates a random localized street address.
*
@@ -187,30 +256,10 @@ export class Address {
* faker.address.streetAddress(false) // '34830 Erdman Hollow'
*/
streetAddress(useFullAddress: boolean = false): string {
- let address = '';
- switch (this.faker.datatype.number(2)) {
- case 0:
- address =
- this.Helpers.replaceSymbolWithNumber('#####') +
- ' ' +
- this.faker.address.streetName();
- break;
- case 1:
- address =
- this.Helpers.replaceSymbolWithNumber('####') +
- ' ' +
- this.faker.address.streetName();
- break;
- case 2:
- address =
- this.Helpers.replaceSymbolWithNumber('###') +
- ' ' +
- this.faker.address.streetName();
- break;
- }
- return useFullAddress
- ? address + ' ' + this.faker.address.secondaryAddress()
- : address;
+ const formats = this.faker.definitions.address.street_address;
+ const format = formats[useFullAddress ? 'full' : 'normal'];
+
+ return this.faker.fake(format);
}
/**
@@ -238,15 +287,17 @@ export class Address {
}
/**
- * Generates a random localized secondary address.
+ * Generates a random localized secondary address. This refers to a specific location at a given address
+ * such as an apartment or room number.
*
* @example
* faker.address.secondaryAddress() // 'Apt. 861'
*/
secondaryAddress(): string {
- return this.Helpers.replaceSymbolWithNumber(
- // TODO ST-DDT 2022-01-30: this.faker.definitions.address.secondary_address
- this.faker.random.arrayElement(['Apt. ###', 'Suite ###'])
+ return this.faker.helpers.replaceSymbolWithNumber(
+ this.faker.random.arrayElement(
+ this.faker.definitions.address.secondary_address
+ )
);
}
@@ -284,37 +335,21 @@ export class Address {
* faker.address.countryCode() // 'SJ'
* faker.address.countryCode('alpha-2') // 'GA'
* faker.address.countryCode('alpha-3') // 'TJK'
- * faker.address.countryCode('unsupported') // 'DJ'
*/
- // TODO ST-DDT 2022-02-10: Limit the parameter to the two values.
- countryCode(alphaCode: string = 'alpha-2'): string {
- if (alphaCode === 'alpha-2') {
- return this.faker.random.arrayElement(
- this.faker.definitions.address.country_code
- );
- }
+ countryCode(alphaCode: 'alpha-2' | 'alpha-3' = 'alpha-2'): string {
+ const key: keyof typeof this.faker.definitions.address =
+ alphaCode === 'alpha-3' ? 'country_code_alpha_3' : 'country_code';
- if (alphaCode === 'alpha-3') {
- return this.faker.random.arrayElement(
- this.faker.definitions.address.country_code_alpha_3
- );
- }
-
- return this.faker.random.arrayElement(
- this.faker.definitions.address.country_code
- );
+ return this.faker.random.arrayElement(this.faker.definitions.address[key]);
}
/**
* Returns a random localized state from this country.
*
- * @param useAbbr This parameter does nothing.
- *
* @example
* faker.address.state() // 'Georgia'
*/
- // TODO @Shinigami92 2022-01-13: useAbbr not in use
- state(useAbbr?: boolean): string {
+ state(): string {
return this.faker.random.arrayElement(this.faker.definitions.address.state);
}
@@ -344,8 +379,8 @@ export class Address {
latitude(max: number = 90, min: number = -90, precision: number = 4): string {
return this.faker.datatype
.number({
- max: max,
- min: min,
+ min,
+ max,
precision: parseFloat((0.0).toPrecision(precision) + '1'),
})
.toFixed(precision);
@@ -455,63 +490,17 @@ export class Address {
* faker.address.nearbyGPSCoordinate([33, -170]) // [ '33.0165', '-170.0636' ]
* faker.address.nearbyGPSCoordinate([33, -170], 1000, true) // [ '37.9163', '-179.2408' ]
*/
- // TODO ST-DDT 2022-02-10: This should use either string or number coords.
+ // TODO ST-DDT 2022-02-10: Allow coordinate parameter to be [string, string].
nearbyGPSCoordinate(
- coordinate?: number[],
+ coordinate?: [number, number],
radius?: number,
isMetric?: boolean
- ): string[] {
- // TODO ST-DDT 2022-02-10: Remove unused code.
- function randomFloat(min: number, max: number): number {
- return Math.random() * (max - min) + min;
- }
- function degreesToRadians(degrees: number): number {
- return degrees * (Math.PI / 180.0);
- }
- function radiansToDegrees(radians: number): number {
- return radians * (180.0 / Math.PI);
- }
- function kilometersToMiles(miles: number): number {
- return miles * 0.621371;
- }
- function coordinateWithOffset(
- coordinate: number[],
- bearing: number,
- distance: number,
- isMetric: boolean
- ): number[] {
- const R = 6378.137; // Radius of the Earth (http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html)
- const d = isMetric ? distance : kilometersToMiles(distance); // Distance in km
-
- const lat1 = degreesToRadians(coordinate[0]); //Current lat point converted to radians
- const lon1 = degreesToRadians(coordinate[1]); //Current long point converted to radians
-
- const lat2 = Math.asin(
- Math.sin(lat1) * Math.cos(d / R) +
- Math.cos(lat1) * Math.sin(d / R) * Math.cos(bearing)
- );
-
- let lon2 =
- lon1 +
- Math.atan2(
- Math.sin(bearing) * Math.sin(d / R) * Math.cos(lat1),
- Math.cos(d / R) - Math.sin(lat1) * Math.sin(lat2)
- );
-
- // Keep longitude in range [-180, 180]
- if (lon2 > degreesToRadians(180)) {
- lon2 = lon2 - degreesToRadians(360);
- } else if (lon2 < degreesToRadians(-180)) {
- lon2 = lon2 + degreesToRadians(360);
- }
-
- return [radiansToDegrees(lat2), radiansToDegrees(lon2)];
- }
-
+ ): [string, string] {
// If there is no coordinate, the best we can do is return a random GPS coordinate.
if (coordinate === undefined) {
return [this.faker.address.latitude(), this.faker.address.longitude()];
}
+
radius = radius || 10.0;
isMetric = isMetric || false;
@@ -521,7 +510,13 @@ export class Address {
// This approach will likely result in a higher density of points near the center.
const randomCoord = coordinateWithOffset(
coordinate,
- degreesToRadians(Math.random() * 360.0),
+ degreesToRadians(
+ this.faker.datatype.number({
+ min: 0,
+ max: 360,
+ precision: 1e-4,
+ })
+ ),
radius,
isMetric
);
diff --git a/src/commerce.ts b/src/commerce.ts
index 741a4a5ff2a..79c485b2333 100644
--- a/src/commerce.ts
+++ b/src/commerce.ts
@@ -89,34 +89,6 @@ export class Commerce {
);
}
- // TODO @Shinigami92 2022-01-12: unimplemented member functions
-
- /*
- categories (num) {
- var categories = [];
-
- do {
- var category = this.faker.random.arrayElement(this.faker.definitions.commerce.department);
- if(categories.indexOf(category) === -1) {
- categories.push(category);
- }
- } while(categories.length < num);
-
- return categories;
- };
-
- */
- /*
- mergeCategories (categories) {
- var separator = this.faker.definitions.separator || " &";
- // TODO: find undefined here
- categories = categories || this.faker.definitions.commerce.categories;
- var commaSeparated = categories.slice(0, -1).join(', ');
-
- return [commaSeparated, categories[categories.length - 1]].join(separator + " ");
- };
- */
-
/**
* Returns an adjective describing a product.
*
diff --git a/src/datatype.ts b/src/datatype.ts
index ba2ebdc4685..50bcb17fda8 100644
--- a/src/datatype.ts
+++ b/src/datatype.ts
@@ -1,17 +1,11 @@
import type { Faker } from '.';
+import { deprecated } from './internal/deprecated';
/**
* Module to generate various primitive values and data types.
*/
export class Datatype {
- constructor(private readonly faker: Faker, seed?: number | number[]) {
- // Use a user provided seed if it is an array or number
- if (Array.isArray(seed) && seed.length) {
- this.faker.mersenne.seed_array(seed);
- } else if (!Array.isArray(seed) && !isNaN(seed)) {
- this.faker.mersenne.seed(seed);
- }
-
+ constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Datatype.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
@@ -27,9 +21,11 @@ export class Datatype {
*
* @param options Maximum value or options object.
* @param options.min Lower bound for generated number. Defaults to `0`.
- * @param options.max Upper bound for generated number. Defaults to `99999`.
+ * @param options.max Upper bound for generated number. Defaults to `min + 99999`.
* @param options.precision Precision of the generated number. Defaults to `1`.
*
+ * @throws When options define `max < min`
+ *
* @example
* faker.datatype.number() // 55422
* faker.datatype.number(100) // 52
@@ -41,40 +37,27 @@ export class Datatype {
number(
options?: number | { min?: number; max?: number; precision?: number }
): number {
- if (typeof options === 'number') {
- options = { max: options };
- }
+ const opts = typeof options === 'number' ? { max: options } : options ?? {};
- options = options ?? {};
+ const min = typeof opts.min === 'number' ? opts.min : 0;
+ let max = typeof opts.max === 'number' ? opts.max : min + 99999;
+ const precision = typeof opts.precision === 'number' ? opts.precision : 1;
- if (typeof options.min === 'undefined') {
- options.min = 0;
- }
-
- if (typeof options.max === 'undefined') {
- options.max = 99999;
- }
-
- if (typeof options.precision === 'undefined') {
- options.precision = 1;
+ if (max < min) {
+ throw new Error(`Max ${max} should be larger then min ${min}`);
}
// Make the range inclusive of the max value
- let max = options.max;
if (max >= 0) {
- max += options.precision;
+ max += precision;
}
- let randomNumber = Math.floor(
- this.faker.mersenne.rand(
- max / options.precision,
- options.min / options.precision
- )
+ const randomNumber = Math.floor(
+ this.faker.mersenne.rand(max / precision, min / precision)
);
- // Workaround problem in Float point arithmetics for e.g. 6681493 / 0.01
- randomNumber = randomNumber / (1 / options.precision);
- return randomNumber;
+ // Workaround problem in float point arithmetics for e.g. 6681493 / 0.01
+ return randomNumber / (1 / precision);
}
/**
@@ -106,7 +89,7 @@ export class Datatype {
for (const p in options) {
opts[p] = options[p];
}
- if (typeof opts.precision === 'undefined') {
+ if (opts.precision == null) {
opts.precision = 0.01;
}
return this.faker.datatype.number(opts);
@@ -130,12 +113,12 @@ export class Datatype {
let min = typeof options === 'number' ? undefined : options?.min;
let max = typeof options === 'number' ? options : options?.max;
- if (typeof min === 'undefined' || min < minMax * -1) {
- min = new Date().setFullYear(1990, 1, 1);
+ if (min == null || min < minMax * -1) {
+ min = Date.UTC(1990, 0);
}
- if (typeof max === 'undefined' || max > minMax) {
- max = new Date().setFullYear(2100, 1, 1);
+ if (max == null || max > minMax) {
+ max = Date.UTC(2100, 0);
}
return new Date(this.faker.datatype.number({ min, max }));
@@ -203,11 +186,35 @@ export class Datatype {
*
* @param length Length of the generated number. Defaults to `1`.
*
+ * @see faker.datatype.hexadecimal()
+ *
* @example
* faker.datatype.hexaDecimal() // '0xb'
* faker.datatype.hexaDecimal(10) // '0xaE13F044fb'
+ *
+ * @deprecated
*/
hexaDecimal(length = 1): string {
+ deprecated({
+ deprecated: 'faker.datatype.hexaDecimal()',
+ proposed: 'faker.datatype.hexadecimal()',
+ since: 'v6.1.2',
+ until: 'v7.0.0',
+ });
+
+ return this.hexadecimal(length);
+ }
+
+ /**
+ * Returns a [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) number.
+ *
+ * @param length Length of the generated number. Defaults to `1`.
+ *
+ * @example
+ * faker.datatype.hexadecimal() // '0xb'
+ * faker.datatype.hexadecimal(10) // '0xaE13F044fb'
+ */
+ hexadecimal(length = 1): string {
let wholeString = '';
for (let i = 0; i < length; i++) {
diff --git a/src/date.ts b/src/date.ts
index 818a946ae9e..c10a80f8fa2 100644
--- a/src/date.ts
+++ b/src/date.ts
@@ -1,4 +1,20 @@
import type { Faker } from '.';
+import type { DateEntryDefinition } from './definitions';
+
+/**
+ * Converts date passed as a string, number or Date to a Date object.
+ * If nothing or a non parseable value is passed, takes current date.
+ *
+ * @param date Date
+ */
+function toDate(date?: string | Date | number): Date {
+ date = new Date(date);
+ if (isNaN(date.valueOf())) {
+ date = new Date();
+ }
+
+ return date;
+}
/**
* Module to generate dates.
@@ -27,12 +43,8 @@ export class _Date {
* faker.date.past(10) // '2017-10-25T21:34:19.488Z'
* faker.date.past(10, '2020-01-01T00:00:00.000Z') // '2017-08-18T02:59:12.350Z'
*/
- past(years?: number, refDate?: string): Date {
- let date = new Date();
- if (typeof refDate !== 'undefined') {
- date = new Date(Date.parse(refDate));
- }
-
+ past(years?: number, refDate?: string | Date | number): Date {
+ const date = toDate(refDate);
const range = {
min: 1000,
max: (years || 1) * 365 * 24 * 3600 * 1000,
@@ -58,12 +70,8 @@ export class _Date {
* faker.date.future(10) // '2030-11-23T09:38:28.710Z'
* faker.date.future(10, '2020-01-01T00:00:00.000Z') // '2020-12-13T22:45:10.252Z'
*/
- future(years?: number, refDate?: string): Date {
- let date = new Date();
- if (typeof refDate !== 'undefined') {
- date = new Date(Date.parse(refDate));
- }
-
+ future(years?: number, refDate?: string | Date | number): Date {
+ const date = toDate(refDate);
const range = {
min: 1000,
max: (years || 1) * 365 * 24 * 3600 * 1000,
@@ -85,13 +93,12 @@ export class _Date {
* @example
* faker.date.between('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z') // '2026-05-16T02:22:53.002Z'
*/
- between(from: string, to: string): Date {
- const fromMilli = Date.parse(from);
- const dateOffset = this.faker.datatype.number(Date.parse(to) - fromMilli);
-
- const newDate = new Date(fromMilli + dateOffset);
+ between(from: string | Date | number, to: string | Date | number): Date {
+ const fromMs = toDate(from).getTime();
+ const toMs = toDate(to).getTime();
+ const dateOffset = this.faker.datatype.number(toMs - fromMs);
- return newDate;
+ return new Date(fromMs + dateOffset);
}
/**
@@ -111,22 +118,18 @@ export class _Date {
* faker.date.betweens('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z', 2)
* // [ 2023-05-02T16:00:00.000Z, 2026-09-01T08:00:00.000Z ]
*/
- betweens(from: string, to: string, num?: number): Date[] {
- if (typeof num === 'undefined') {
- num = 3;
- }
- const newDates: Date[] = [];
- let fromMilli = Date.parse(from);
- const dateOffset = (Date.parse(to) - fromMilli) / (num + 1);
- let lastDate: string | Date = from;
- for (let i = 0; i < num; i++) {
- // TODO @Shinigami92 2022-01-11: It may be a bug that `lastDate` is passed to parse if it's a `Date` not a `string`
- // @ts-expect-error
- fromMilli = Date.parse(lastDate);
- lastDate = new Date(fromMilli + dateOffset);
- newDates.push(lastDate);
+ betweens(
+ from: string | Date | number,
+ to: string | Date | number,
+ num: number = 3
+ ): Date[] {
+ const dates: Date[] = [];
+
+ while (dates.length < num) {
+ dates.push(this.between(from, to));
}
- return newDates;
+
+ return dates.sort((a, b) => a.getTime() - b.getTime());
}
/**
@@ -142,12 +145,8 @@ export class _Date {
* faker.date.recent(10) // '2022-01-29T06:12:12.829Z'
* faker.date.recent(10, '2020-01-01T00:00:00.000Z') // '2019-12-27T18:11:19.117Z'
*/
- recent(days?: number, refDate?: string): Date {
- let date = new Date();
- if (typeof refDate !== 'undefined') {
- date = new Date(Date.parse(refDate));
- }
-
+ recent(days?: number, refDate?: string | Date | number): Date {
+ const date = toDate(refDate);
const range = {
min: 1000,
max: (days || 1) * 24 * 3600 * 1000,
@@ -173,12 +172,8 @@ export class _Date {
* faker.date.soon(10) // '2022-02-11T05:14:39.138Z'
* faker.date.soon(10, '2020-01-01T00:00:00.000Z') // '2020-01-01T02:40:44.990Z'
*/
- soon(days?: number, refDate?: string): Date {
- let date = new Date();
- if (typeof refDate !== 'undefined') {
- date = new Date(Date.parse(refDate));
- }
-
+ soon(days?: number, refDate?: string | Date | number): Date {
+ const date = toDate(refDate);
const range = {
min: 1000,
max: (days || 1) * 24 * 3600 * 1000,
@@ -205,23 +200,24 @@ export class _Date {
* faker.date.month({ abbr: true, context: true }) // 'Sep'
*/
month(options?: { abbr?: boolean; context?: boolean }): string {
- options = options || {};
+ const abbr = options?.abbr ?? false;
+ const context = options?.context ?? false;
- let type = 'wide';
- if (options.abbr) {
- type = 'abbr';
- }
- if (
- options.context &&
- typeof this.faker.definitions.date.month[type + '_context'] !==
- 'undefined'
- ) {
- type += '_context';
+ const source = this.faker.definitions.date.month;
+ let type: keyof DateEntryDefinition;
+ if (abbr) {
+ if (context && source['abbr_context'] != null) {
+ type = 'abbr_context';
+ } else {
+ type = 'abbr';
+ }
+ } else if (context && source['wide_context'] != null) {
+ type = 'wide_context';
+ } else {
+ type = 'wide';
}
- const source = this.faker.definitions.date.month[type];
-
- return this.faker.random.arrayElement(source);
+ return this.faker.random.arrayElement(source[type]);
}
/**
@@ -238,22 +234,23 @@ export class _Date {
* faker.date.weekday({ abbr: true, context: true }) // 'Fri'
*/
weekday(options?: { abbr?: boolean; context?: boolean }): string {
- options = options || {};
+ const abbr = options?.abbr ?? false;
+ const context = options?.context ?? false;
- let type = 'wide';
- if (options.abbr) {
- type = 'abbr';
- }
- if (
- options.context &&
- typeof this.faker.definitions.date.weekday[type + '_context'] !==
- 'undefined'
- ) {
- type += '_context';
+ const source = this.faker.definitions.date.weekday;
+ let type: keyof DateEntryDefinition;
+ if (abbr) {
+ if (context && source['abbr_context'] != null) {
+ type = 'abbr_context';
+ } else {
+ type = 'abbr';
+ }
+ } else if (context && source['wide_context'] != null) {
+ type = 'wide_context';
+ } else {
+ type = 'wide';
}
- const source = this.faker.definitions.date.weekday[type];
-
- return this.faker.random.arrayElement(source);
+ return this.faker.random.arrayElement(source[type]);
}
}
diff --git a/src/definitions/address.ts b/src/definitions/address.ts
index a5bf2d1c861..c5d5409f926 100644
--- a/src/definitions/address.ts
+++ b/src/definitions/address.ts
@@ -7,10 +7,7 @@ export interface AddressDefinitions {
/**
* Postcodes patterns by state
*/
- // TODO ST-DDT 2022-01-31: address.zipCodeByState() expects only { [state: string]: { min: number; max: number } }
- postcode_by_state:
- | string[]
- | { [state: string]: { min: number; max: number } };
+ postcode_by_state: { [state: string]: { min: number; max: number } };
/**
* Postcodes patterns (Fake-Pattern | Fake-Pattern[]).
*/
@@ -57,6 +54,11 @@ export interface AddressDefinitions {
*/
direction_abbr: string[];
+ /**
+ * The pattern used to generate building numbers.
+ */
+ building_number: string[];
+
/**
* Common street prefixes
*/
@@ -66,17 +68,31 @@ export interface AddressDefinitions {
*/
street_suffix: string[];
+ /**
+ * The pattern used to generate street addresses.
+ */
+ street_address: {
+ /**
+ * The fake pattern to generate only the street address.
+ */
+ normal: string;
+ /**
+ * The fake pattern to generate the full street address including the secondary address.
+ */
+ full: string;
+ };
+
/**
* The address "inside" an address/e.g. an apartment or office.
*/
secondary_address: string[];
/**
- * The ISO-3166-1 ALPHA-2 country codes
+ * The ISO-3166-1 ALPHA-2 country codes related to this locale.
*/
country_code: string[];
/**
- * The ISO-3166-1 ALPHA-3 country codes
+ * The ISO-3166-1 ALPHA-3 country codes related to this locale.
*/
country_code_alpha_3: string[];
@@ -103,9 +119,12 @@ export const ADDRESS = allOf()(
'direction_abbr',
'direction',
+ 'building_number',
+
'street_prefix',
'street_suffix',
+ 'street_address',
'secondary_address',
'country_code',
diff --git a/src/definitions/utils.ts b/src/definitions/utils.ts
index b7b826a1657..03764c1dfeb 100644
--- a/src/definitions/utils.ts
+++ b/src/definitions/utils.ts
@@ -1,6 +1,10 @@
// https://stackoverflow.com/a/53395649/4573065
export type AllOf = ['Needs to be all of', T];
+/**
+ * Creates a function that requires all keys of the generic type to be used as parameters.
+ * The function itself will return the given parameters.
+ */
export function allOf(): (
...array: U & ([T] extends [U[number]] ? unknown : AllOf[])
) => U & ([T] extends [U[number]] ? unknown : AllOf[]) {
diff --git a/src/errors/faker-error.ts b/src/errors/faker-error.ts
new file mode 100644
index 00000000000..e38bdf470fb
--- /dev/null
+++ b/src/errors/faker-error.ts
@@ -0,0 +1,4 @@
+/**
+ * An error instance that will be thrown by faker.
+ */
+export class FakerError extends Error {}
diff --git a/src/fake.ts b/src/fake.ts
index d56b4794741..d478d01e4e1 100644
--- a/src/fake.ts
+++ b/src/fake.ts
@@ -1,4 +1,5 @@
import type { Faker } from '.';
+import { FakerError } from './errors/faker-error';
/**
* Generator method for combining faker methods based on string input.
@@ -15,22 +16,35 @@ export class Fake {
}
/**
- * Generator method for combining faker methods based on string input.
+ * Generator for combining faker methods based on a static string input.
*
- * This will check the given string for placeholders and replace them by calling the specified faker method.
- * E.g. the input `Hi, my name is {{name.firstName}}!`,
- * will use the `faker.name.firstName()` method to resolve the placeholder.
- * It is also possible to combine static text with placeholders,
- * since only the parts inside the double braces `{{placeholder}}` are replaced.
- * The replacement process is repeated until all placeholders have been replaced by static text.
- * It is also possible to provide the called method with additional parameters by adding parentheses.
- * This method will first attempt to parse the parameters as json, if that isn't possible it will use them as string.
- * E.g. `You can call me at {{phone.phoneNumber(+!# !## #### #####!)}}.`
- * Currently it isn't possible to set more than a single parameter this way.
+ * Note: We recommend using string template literals instead of `fake()`,
+ * which are faster and strongly typed (if you are using TypeScript),
+ * e.g. ``const address = `${faker.address.zipCode()} ${faker.address.city()}`;``
*
- * Please note that is NOT possible to use any non-faker methods or plain js script in there.
+ * This method is useful if you have to build a random string from a static, non-executable source
+ * (e.g. string coming from a user, stored in a database or a file).
*
- * @param str The format string that will get interpolated. May not be empty.
+ * It checks the given string for placeholders and replaces them by calling faker methods:
+ *
+ * ```js
+ * const hello = faker.fake('Hi, my name is {{name.firstName}} {{name.lastName}}!')
+ * ```
+ *
+ * This would use the `faker.name.firstName()` and `faker.name.lastName()` method to resolve the placeholders respectively.
+ *
+ * It is also possible to provide parameters. At first, they will be parsed as json,
+ * and if that isn't possible, we will fall back to string:
+ *
+ * ```js
+ * const message = faker.fake(`You can call me at {{phone.phoneNumber(+!# !## #### #####!)}}.')
+ * ```
+ *
+ * Currently it is not possible to set more than a single parameter.
+ *
+ * It is also NOT possible to use any non-faker methods or plain javascript in such templates.
+ *
+ * @param str The template string that will get interpolated. Must not be empty.
*
* @see faker.helpers.mustache() to use custom functions for resolution.
*
@@ -43,32 +57,25 @@ export class Fake {
* faker.fake('I flipped the coin an got: {{random.arrayElement(["heads", "tails"])}}') // 'I flipped the coin an got: tails'
*/
fake(str: string): string {
- // setup default response as empty string
- let res = '';
-
// if incoming str parameter is not provided, return error message
if (typeof str !== 'string' || str.length === 0) {
- throw new Error('string parameter is required!');
+ throw new FakerError('string parameter is required!');
}
// find first matching {{ and }}
- const start = str.search('{{');
- const end = str.search('}}');
+ const start = str.search(/{{[a-z]/);
+ const end = str.indexOf('}}', start);
// if no {{ and }} is found, we are done
if (start === -1 || end === -1) {
return str;
}
- // console.log('attempting to parse', str);
-
// extract method name from between the {{ }} that we found
// for example: {{name.firstName}}
- const token = str.substr(start + 2, end - start - 2);
+ const token = str.substring(start + 2, end + 2);
let method = token.replace('}}', '').replace('{{', '');
- // console.log('method', method)
-
// extract method parameters
const regExp = /\(([^)]+)\)/;
const matches = regExp.exec(method);
@@ -81,22 +88,22 @@ export class Fake {
// split the method into module and function
const parts = method.split('.');
- if (typeof this.faker[parts[0]] === 'undefined') {
- throw new Error('Invalid module: ' + parts[0]);
+ if (this.faker[parts[0]] == null) {
+ throw new FakerError('Invalid module: ' + parts[0]);
}
- if (typeof this.faker[parts[0]][parts[1]] === 'undefined') {
- throw new Error('Invalid method: ' + parts[0] + '.' + parts[1]);
+ if (this.faker[parts[0]][parts[1]] == null) {
+ throw new FakerError('Invalid method: ' + parts[0] + '.' + parts[1]);
}
// assign the function from the module.function namespace
- let fn: (args?: any) => string = this.faker[parts[0]][parts[1]];
+ let fn: (args?: unknown) => string = this.faker[parts[0]][parts[1]];
fn = fn.bind(this);
// If parameters are populated here, they are always going to be of string type
// since we might actually be dealing with an object or array,
// we always attempt to the parse the incoming parameters into JSON
- let params: any;
+ let params: unknown;
// Note: we experience a small performance hit here due to JSON.parse try / catch
// If anyone actually needs to optimize this specific code path, please open a support issue on github
try {
@@ -108,13 +115,18 @@ export class Fake {
let result: string;
if (typeof params === 'string' && params.length === 0) {
- result = fn();
+ result = String(fn());
} else {
- result = fn(params);
+ result = String(fn(params));
}
- // replace the found tag with the returned fake value
- res = str.replace('{{' + token + '}}', result);
+ // Replace the found tag with the returned fake value
+ // We cannot use string.replace here because the result might contain evaluated characters
+ const res = str.substring(0, start) + result + str.substring(end + 2);
+
+ if (res === '') {
+ return '';
+ }
// return the response recursively until we are done finding all tags
return this.fake(res);
diff --git a/src/faker.ts b/src/faker.ts
index 83f59a06259..7b74d58c9ac 100644
--- a/src/faker.ts
+++ b/src/faker.ts
@@ -7,6 +7,7 @@ import { Datatype } from './datatype';
import { _Date } from './date';
import type { LocaleDefinition } from './definitions';
import { DEFINITIONS } from './definitions';
+import { FakerError } from './errors/faker-error';
import { Fake } from './fake';
import { Finance } from './finance';
import { Git } from './git';
@@ -36,7 +37,7 @@ export type UsableLocale = LiteralUnion;
export type UsedLocales = Partial>;
export interface FakerOptions {
- locales?: UsedLocales;
+ locales: UsedLocales;
locale?: UsableLocale;
localeFallback?: UsableLocale;
}
@@ -70,8 +71,6 @@ export class Faker {
readonly finance = new Finance(this);
readonly git: Git = new Git(this);
readonly hacker: Hacker = new Hacker(this);
- // TODO @Shinigami92 2022-01-12: iban was not used
- // readonly iban = new (require('./iban'))(this);
readonly image: Image = new Image(this);
readonly internet: Internet = new Internet(this);
readonly lorem: Lorem = new Lorem(this);
@@ -83,56 +82,68 @@ export class Faker {
readonly vehicle: Vehicle = new Vehicle(this);
readonly word: Word = new Word(this);
- constructor(opts: FakerOptions = {}) {
- this.locales = this.locales || opts.locales || {};
- this.locale = this.locale || opts.locale || 'en';
- this.localeFallback = this.localeFallback || opts.localeFallback || 'en';
+ constructor(opts: FakerOptions) {
+ if (!opts) {
+ throw new FakerError(
+ 'Options with at least one entry in locales must be provided'
+ );
+ }
+
+ if (Object.keys(opts.locales ?? {}).length === 0) {
+ throw new FakerError(
+ 'At least one entry in locales must be provided in the locales parameter'
+ );
+ }
+
+ this.locales = opts.locales;
+ this.locale = opts.locale || 'en';
+ this.localeFallback = opts.localeFallback || 'en';
this.loadDefinitions();
}
/**
- * Load the definitions contained in the locales file for the given types
+ * Load the definitions contained in the locales file for the given types.
+ *
+ * Background: Certain localization sets contain less data then others.
+ * In the case of a missing definition, use the localeFallback's values
+ * to substitute the missing data.
*/
private loadDefinitions(): void {
// TODO @Shinigami92 2022-01-11: Find a way to load this even more dynamically
// In a way so that we don't accidentally miss a definition
- Object.entries(DEFINITIONS).forEach(([t, v]) => {
- if (typeof this.definitions[t] === 'undefined') {
- this.definitions[t] = {};
+ for (const [moduleName, entryNames] of Object.entries(DEFINITIONS)) {
+ if (typeof entryNames === 'string') {
+ // For 'title' and 'separator'
+ Object.defineProperty(this.definitions, moduleName, {
+ get: (): unknown /* string */ =>
+ this.locales[this.locale][moduleName] ??
+ this.locales[this.localeFallback][moduleName],
+ });
+ continue;
}
- if (typeof v === 'string') {
- this.definitions[t] = v;
- return;
+ if (this.definitions[moduleName] == null) {
+ this.definitions[moduleName] = {};
}
- v.forEach((p) => {
- Object.defineProperty(this.definitions[t], p, {
- get: () => {
- if (
- typeof this.locales[this.locale][t] === 'undefined' ||
- typeof this.locales[this.locale][t][p] === 'undefined'
- ) {
- // certain localization sets contain less data then others.
- // in the case of a missing definition, use the default localeFallback
- // to substitute the missing set data
- // throw new Error('unknown property ' + d + p)
- return this.locales[this.localeFallback][t][p];
- } else {
- // return localized data
- return this.locales[this.locale][t][p];
- }
- },
+ for (const entryName of entryNames) {
+ Object.defineProperty(this.definitions[moduleName], entryName, {
+ get: (): unknown =>
+ this.locales[this.locale][moduleName]?.[entryName] ??
+ this.locales[this.localeFallback][moduleName]?.[entryName],
});
- });
- });
+ }
+ }
}
- seed(value?: number | number[]): void {
- this.seedValue = value;
- this.random = new Random(this, this.seedValue);
- this.datatype = new Datatype(this, this.seedValue);
+ seed(seed?: number | number[]): void {
+ this.seedValue = seed;
+ if (Array.isArray(seed) && seed.length) {
+ this.mersenne.seed_array(seed);
+ } else if (!Array.isArray(seed) && !isNaN(seed)) {
+ this.mersenne.seed(seed);
+ }
}
/**
diff --git a/src/finance.ts b/src/finance.ts
index a25f6443a9b..5581ad4eac4 100644
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -1,4 +1,5 @@
import type { Faker } from '.';
+import { FakerError } from './errors/faker-error';
import type { Helpers } from './helpers';
import ibanLib from './iban';
@@ -49,7 +50,9 @@ export class Finance {
*/
accountName(): string {
return [
- this.Helpers.randomize(this.faker.definitions.finance.account_type),
+ this.faker.random.arrayElement(
+ this.faker.definitions.finance.account_type
+ ),
'Account',
].join(' ');
}
@@ -90,8 +93,7 @@ export class Finance {
*/
mask(length?: number, parens?: boolean, ellipsis?: boolean): string {
// set defaults
- length =
- length === 0 || !length || typeof length === 'undefined' ? 4 : length;
+ length = length || 4;
parens = parens == null ? true : parens;
ellipsis = ellipsis == null ? true : ellipsis;
@@ -161,7 +163,7 @@ export class Finance {
* faker.finance.transactionType() // 'payment'
*/
transactionType(): string {
- return this.Helpers.randomize(
+ return this.faker.random.arrayElement(
this.faker.definitions.finance.transaction_type
);
}
@@ -249,7 +251,7 @@ export class Finance {
/**
* Generates a random credit card number.
*
- * @param provider The (lowercase) name of the provider or the format used to generate one.
+ * @param provider The name of the provider (case insensitive) or the format used to generate one.
*
* @example
* faker.finance.creditCardNumber() // '4427163488668'
@@ -258,32 +260,18 @@ export class Finance {
*/
creditCardNumber(provider = ''): string {
let format: string;
- let formats: string | string[];
const localeFormat = this.faker.definitions.finance.credit_card;
- if (provider in localeFormat) {
- formats = localeFormat[provider]; // there could be multiple formats
- if (typeof formats === 'string') {
- format = formats;
- } else {
- format = this.faker.random.arrayElement(formats);
- }
+ const normalizedProvider = provider.toLowerCase();
+ if (normalizedProvider in localeFormat) {
+ format = this.faker.random.arrayElement(localeFormat[normalizedProvider]);
} else if (provider.match(/#/)) {
// The user chose an optional scheme
format = provider;
} else {
// Choose a random provider
- // TODO ST-DDT 2022-01-30: #375 This is impossible to access
- if (typeof localeFormat === 'string') {
- format = localeFormat;
- } else if (typeof localeFormat === 'object') {
- // Credit cards are in a object structure
- formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
- if (typeof formats === 'string') {
- format = formats;
- } else {
- format = this.faker.random.arrayElement(formats);
- }
- }
+ // Credit cards are in an object structure
+ const formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
+ format = this.faker.random.arrayElement(formats);
}
format = format.replace(/\//g, '');
return this.Helpers.replaceCreditCardSymbols(format);
@@ -310,7 +298,7 @@ export class Finance {
* faker.finance.ethereumAddress() // '0xf03dfeecbafc5147241cc4c4ca20b3c9dfd04c4a'
*/
ethereumAddress(): string {
- const address = this.faker.datatype.hexaDecimal(40).toLowerCase();
+ const address = this.faker.datatype.hexadecimal(40).toLowerCase();
return address;
}
@@ -342,13 +330,12 @@ export class Finance {
}
if (!ibanFormat) {
- throw new Error('Country code ' + countryCode + ' not supported.');
+ throw new FakerError('Country code ' + countryCode + ' not supported.');
}
let s = '';
let count = 0;
- for (let b = 0; b < ibanFormat.bban.length; b++) {
- const bban = ibanFormat.bban[b];
+ for (const bban of ibanFormat.bban) {
let c = bban.count;
count += bban.count;
while (c > 0) {
diff --git a/src/git.ts b/src/git.ts
index b77b79cb988..6c82e48df4b 100644
--- a/src/git.ts
+++ b/src/git.ts
@@ -61,18 +61,17 @@ export class Git {
*/
commitEntry(options: { merge?: boolean } = {}): string {
// TODO @Shinigami92 2022-01-11: We may want to make it configurable to use just `\n` instead of `\r\n`
- let entry = 'commit {{git.commitSha}}\r\n';
+ let entry = `commit ${this.commitSha()}\r\n`;
if (options.merge || this.faker.datatype.number({ min: 0, max: 4 }) === 0) {
- entry += 'Merge: {{git.shortSha}} {{git.shortSha}}\r\n';
+ entry += `Merge: ${this.shortSha()}} ${this.shortSha()}\r\n`;
}
- entry +=
- 'Author: {{name.firstName}} {{name.lastName}} <{{internet.email}}>\r\n';
- entry += 'Date: ' + this.faker.date.recent().toString() + '\r\n';
- entry += '\r\n\xa0\xa0\xa0\xa0{{git.commitMessage}}\r\n';
+ entry += `Author: ${this.faker.name.firstName()} ${this.faker.name.lastName()} <${this.faker.internet.email()}>\r\n`;
+ entry += `Date: ${this.faker.date.recent().toString()}\r\n`;
+ entry += `\r\n\xa0\xa0\xa0\xa0${this.commitMessage()}\r\n`;
- return this.faker.fake(entry);
+ return entry;
}
/**
@@ -82,8 +81,7 @@ export class Git {
* faker.git.commitMessage() // 'reboot cross-platform driver'
*/
commitMessage(): string {
- const format = '{{hacker.verb}} {{hacker.adjective}} {{hacker.noun}}';
- return this.faker.fake(format);
+ return `${this.faker.hacker.verb()} ${this.faker.hacker.adjective()} ${this.faker.hacker.noun()}`;
}
/**
diff --git a/src/helpers.ts b/src/helpers.ts
index 0f970dbacbb..e451eaab130 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -1,4 +1,5 @@
import type { Faker } from '.';
+import { deprecated } from './internal/deprecated';
/**
* A full card with various details.
@@ -137,11 +138,18 @@ export class Helpers {
* @example
* faker.helpers.randomize() // 'c'
* faker.helpers.randomize([1, 2, 3]) // '2'
+ *
+ * @deprecated
*/
- // TODO ST-DDT 2022-02-06: Mark as deprecated
randomize(
array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray
): T {
+ deprecated({
+ deprecated: 'faker.helpers.randomize()',
+ proposed: 'faker.random.arrayElement()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.random.arrayElement(array);
}
@@ -265,7 +273,6 @@ export class Helpers {
* faker.helpers.replaceCreditCardSymbols() // '6453-4876-8626-8995-3779'
* faker.helpers.replaceCreditCardSymbols('1234-[4-9]-##!!-L') // '1234-9-5298-2'
*/
-
replaceCreditCardSymbols(
string: string = '6453-####-####-####-###L',
symbol: string = '#'
@@ -296,9 +303,7 @@ export class Helpers {
.split('')
.map((num) => parseInt(num));
const checkNum = getCheckBit(numberList);
- // TODO @Shinigami92 2022-01-11: I assume this should be converted to string
- // @ts-expect-error
- return string.replace('L', checkNum);
+ return string.replace('L', String(checkNum));
}
/**
@@ -342,9 +347,12 @@ export class Helpers {
const RANGE_REP_REG = /(.)\{(\d+)\,(\d+)\}/;
const REP_REG = /(.)\{(\d+)\}/;
const RANGE_REG = /\[(\d+)\-(\d+)\]/;
- let min, max, tmp, repetitions;
+ let min: number;
+ let max: number;
+ let tmp: number;
+ let repetitions: number;
let token = string.match(RANGE_REP_REG);
- while (token !== null) {
+ while (token != null) {
min = parseInt(token[2]);
max = parseInt(token[3]);
// switch min and max
@@ -362,7 +370,7 @@ export class Helpers {
}
// Deal with repeat `{num}`
token = string.match(REP_REG);
- while (token !== null) {
+ while (token != null) {
repetitions = parseInt(token[2]);
string =
string.slice(0, token.index) +
@@ -374,7 +382,7 @@ export class Helpers {
//TODO: implement for letters e.g. [0-9a-zA-Z] etc.
token = string.match(RANGE_REG);
- while (token !== null) {
+ while (token != null) {
min = parseInt(token[1]); // This time we are not capturing the char before `[]`
max = parseInt(token[2]);
// switch min and max
@@ -405,15 +413,13 @@ export class Helpers {
* faker.helpers.shuffle(['a', 'b', 'c']) // [ 'b', 'c', 'a' ]
*/
shuffle(o?: T[]): T[] {
- if (typeof o === 'undefined' || o.length === 0) {
+ if (o == null || o.length === 0) {
return o || [];
}
- // TODO ST-DDT 2022-02-06: This default will never be taken!?
- o = o || (['a', 'b', 'c'] as unknown as T[]);
- for (let x: T, j: number, i = o.length - 1; i > 0; --i) {
- j = this.faker.datatype.number(i);
- x = o[i];
+ for (let i = o.length - 1; i > 0; --i) {
+ const j = this.faker.datatype.number(i);
+ const x = o[i];
o[i] = o[j];
o[j] = x;
}
@@ -434,9 +440,9 @@ export class Helpers {
* faker.helpers.uniqueArray(faker.definitions.name.first_name, 6)
* faker.helpers.uniqueArray(["Hello", "World", "Goodbye"], 2)
*/
- uniqueArray(source: T[] | (() => T), length: number): T[] {
+ uniqueArray(source: readonly T[] | (() => T), length: number): T[] {
if (Array.isArray(source)) {
- const set = new Set(source);
+ const set = new Set(source);
const array = Array.from(set);
return this.faker.helpers.shuffle(array).splice(0, length);
}
@@ -447,11 +453,10 @@ export class Helpers {
set.add(source());
}
}
- } finally {
- // TODO @Shinigami92 2022-01-21: Check what to do here
- // eslint-disable-next-line no-unsafe-finally
- return Array.from(set);
+ } catch {
+ // Ignore
}
+ return Array.from(set);
}
/**
@@ -470,22 +475,19 @@ export class Helpers {
*/
mustache(
str: string | undefined,
- data: Record<
- string,
- string | ((substring: string, ...args: any[]) => string)
- >
+ data: Record[1]>
): string {
- if (typeof str === 'undefined') {
+ if (str == null) {
return '';
}
for (const p in data) {
const re = new RegExp('{{' + p + '}}', 'g');
- str = str.replace(
- re,
- // TODO @Shinigami92 2022-01-14: Try to improve the type or maybe use `if`
- // @ts-expect-error
- data[p]
- );
+ const value = data[p];
+ if (typeof value === 'string') {
+ str = str.replace(re, value);
+ } else {
+ str = str.replace(re, value);
+ }
}
return str;
}
@@ -502,8 +504,15 @@ export class Helpers {
* // address: {
* // streetA: 'Drake Avenue',
* // ...
+ * @deprecated If you need some specific object you should create your own method.
*/
createCard(): Card {
+ deprecated({
+ deprecated: 'helpers.createCard()',
+ proposed: 'a self-build function',
+ since: 'v6.1.0',
+ until: 'v7.0.0',
+ });
return {
name: this.faker.name.findName(),
username: this.faker.internet.userName(),
@@ -569,8 +578,15 @@ export class Helpers {
* // email: 'Eveline.Brekke56.Hoppe@yahoo.com',
* // dob: 1964-05-06T05:14:37.874Z,
* // ...
+ * @deprecated If you need some specific object you should create your own method.
*/
contextualCard(): ContextualCard {
+ deprecated({
+ deprecated: 'helpers.contextualCard()',
+ proposed: 'a self-build function',
+ since: 'v6.1.0',
+ until: 'v7.0.0',
+ });
const name = this.faker.name.firstName();
const userName = this.faker.internet.userName(name);
return {
@@ -580,8 +596,6 @@ export class Helpers {
email: this.faker.internet.email(userName),
dob: this.faker.date.past(
50,
- // TODO @Shinigami92 2022-01-14: We may need to convert this to a string
- // @ts-expect-error
new Date('Sat Sep 20 1992 21:35:02 GMT+0200 (CEST)')
),
phone: this.faker.phone.phoneNumber(),
@@ -616,8 +630,15 @@ export class Helpers {
* // address: {
* // street: 'McKenzie Estates',
* // ....
+ * @deprecated If you need some specific object you should create your own method.
*/
userCard(): UserCard {
+ deprecated({
+ deprecated: 'helpers.userCard()',
+ proposed: 'a self-build function',
+ since: 'v6.1.0',
+ until: 'v7.0.0',
+ });
return {
name: this.faker.name.findName(),
username: this.faker.internet.userName(),
@@ -664,7 +685,9 @@ export class Helpers {
name: [this.faker.finance.accountName(), this.faker.finance.mask()].join(
' '
),
- type: this.randomize(this.faker.definitions.finance.transaction_type),
+ type: this.faker.random.arrayElement(
+ this.faker.definitions.finance.transaction_type
+ ),
account: this.faker.finance.account(),
};
}
diff --git a/src/iban.ts b/src/iban.ts
index 0c90253423d..2e67f2813a6 100644
--- a/src/iban.ts
+++ b/src/iban.ts
@@ -30,21 +30,13 @@ export = {
pattern10: ['01', '02', '03', '04', '05', '06', '07', '08', '09'],
pattern100: ['001', '002', '003', '004', '005', '006', '007', '008', '009'],
toDigitString: (str: string): string =>
- str.replace(
- /[A-Z]/gi,
- (match) =>
- // TODO @Shinigami92 2022-01-13: This needs to be converted to string
- // @ts-expect-error
- match.toUpperCase().charCodeAt(0) - 55
+ str.replace(/[A-Z]/gi, (match) =>
+ String(match.toUpperCase().charCodeAt(0) - 55)
),
mod97: (digitStr: string): number => {
let m = 0;
for (let i = 0; i < digitStr.length; i++) {
- m =
- (m * 10 +
- // @ts-expect-error: We need to convert this properly
- (digitStr[i] | 0)) %
- 97;
+ m = (m * 10 + +digitStr[i]) % 97;
}
return m;
},
@@ -206,8 +198,12 @@ export = {
},
{
country: 'CR',
- total: 21,
+ total: 22,
bban: [
+ {
+ type: 'n',
+ count: 1,
+ },
{
type: 'n',
count: 3,
@@ -217,7 +213,7 @@ export = {
count: 14,
},
],
- format: 'CRkk bbbc cccc cccc cccc c',
+ format: 'CRkk xbbb cccc cccc cccc cc',
},
{
country: 'HR',
@@ -1147,7 +1143,6 @@ export = {
},
],
iso3166: [
- 'AC',
'AD',
'AE',
'AF',
@@ -1155,7 +1150,6 @@ export = {
'AI',
'AL',
'AM',
- 'AN',
'AO',
'AQ',
'AR',
@@ -1182,7 +1176,6 @@ export = {
'BR',
'BS',
'BT',
- 'BU',
'BV',
'BW',
'BY',
@@ -1190,7 +1183,6 @@ export = {
'CA',
'CC',
'CD',
- 'CE',
'CF',
'CG',
'CH',
@@ -1200,25 +1192,19 @@ export = {
'CM',
'CN',
'CO',
- 'CP',
'CR',
- 'CS',
- 'CS',
'CU',
'CV',
'CW',
'CX',
'CY',
'CZ',
- 'DD',
'DE',
- 'DG',
'DJ',
'DK',
'DM',
'DO',
'DZ',
- 'EA',
'EC',
'EE',
'EG',
@@ -1226,14 +1212,12 @@ export = {
'ER',
'ES',
'ET',
- 'EU',
'FI',
'FJ',
'FK',
'FM',
'FO',
'FR',
- 'FX',
'GA',
'GB',
'GD',
@@ -1259,7 +1243,6 @@ export = {
'HR',
'HT',
'HU',
- 'IC',
'ID',
'IE',
'IL',
@@ -1329,7 +1312,6 @@ export = {
'NO',
'NP',
'NR',
- 'NT',
'NU',
'NZ',
'OM',
@@ -1370,12 +1352,10 @@ export = {
'SR',
'SS',
'ST',
- 'SU',
'SV',
'SX',
'SY',
'SZ',
- 'TA',
'TC',
'TD',
'TF',
@@ -1407,12 +1387,11 @@ export = {
'VU',
'WF',
'WS',
+ 'XK',
'YE',
'YT',
- 'YU',
'ZA',
'ZM',
- 'ZR',
'ZW',
],
};
diff --git a/src/image.ts b/src/image.ts
index 31f8d651d7a..fc8eaf153a5 100644
--- a/src/image.ts
+++ b/src/image.ts
@@ -35,9 +35,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.image() // 'http://placeimg.com/640/480/city'
- * faker.image.image(1234, 2345) // 'http://placeimg.com/1234/2345/sports'
- * faker.image.image(1234, 2345, true) // 'http://placeimg.com/1234/2345/nature?56789'
+ * faker.image.image() // 'http://loremflickr.com/640/480/city'
+ * faker.image.image(1234, 2345) // 'http://loremflickr.com/1234/2345/sports'
+ * faker.image.image(1234, 2345, true) // 'http://loremflickr.com/1234/2345/nature?56789'
*/
image(width?: number, height?: number, randomize?: boolean): string {
const categories = [
@@ -83,11 +83,11 @@ export class Image {
* @param https When true, return a `https` url. Otherwise, return a `http` url.
*
* @example
- * faker.image.imageUrl() // 'http://placeimg.com/640/480'
- * faker.image.imageUrl(1234, 2345) // 'http://placeimg.com/1234/2345'
- * faker.image.imageUrl(1234, 2345, 'cat') // 'http://placeimg.com/1234/2345/cat'
- * faker.image.imageUrl(1234, 2345, 'cat', true) // 'http://placeimg.com/1234/2345/cat?6849'
- * faker.image.imageUrl(1234, 2345, 'cat', true, true) // 'https://placeimg.com/1234/2345/cat?56789'
+ * faker.image.imageUrl() // 'http://loremflickr.com/640/480'
+ * faker.image.imageUrl(1234, 2345) // 'http://loremflickr.com/1234/2345'
+ * faker.image.imageUrl(1234, 2345, 'cat') // 'http://loremflickr.com/1234/2345/cat'
+ * faker.image.imageUrl(1234, 2345, 'cat', true) // 'http://loremflickr.com/1234/2345/cat?6849'
+ * faker.image.imageUrl(1234, 2345, 'cat', true, true) // 'https://loremflickr.com/1234/2345/cat?56789'
*/
imageUrl(
width?: number,
@@ -99,11 +99,11 @@ export class Image {
width = width || 640;
height = height || 480;
let protocol = 'http://';
- if (typeof https !== 'undefined' && https === true) {
+ if (https === true) {
protocol = 'https://';
}
- let url = `${protocol}placeimg.com/${width}/${height}`;
- if (typeof category !== 'undefined') {
+ let url = `${protocol}loremflickr.com/${width}/${height}`;
+ if (category != null) {
url += '/' + category;
}
@@ -122,9 +122,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.abstract() // 'http://placeimg.com/640/480/abstract'
- * faker.image.abstract(1234, 2345) // 'http://placeimg.com/1234/2345/abstract'
- * faker.image.abstract(1234, 2345, true) // 'http://placeimg.com/1234/2345/abstract?56789'
+ * faker.image.abstract() // 'http://loremflickr.com/640/480/abstract'
+ * faker.image.abstract(1234, 2345) // 'http://loremflickr.com/1234/2345/abstract'
+ * faker.image.abstract(1234, 2345, true) // 'http://loremflickr.com/1234/2345/abstract?56789'
*/
abstract(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'abstract', randomize);
@@ -138,9 +138,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.animals() // 'http://placeimg.com/640/480/animals'
- * faker.image.animals(1234, 2345) // 'http://placeimg.com/1234/2345/animals'
- * faker.image.animals(1234, 2345, true) // 'http://placeimg.com/1234/2345/animals?56789'
+ * faker.image.animals() // 'http://loremflickr.com/640/480/animals'
+ * faker.image.animals(1234, 2345) // 'http://loremflickr.com/1234/2345/animals'
+ * faker.image.animals(1234, 2345, true) // 'http://loremflickr.com/1234/2345/animals?56789'
*/
animals(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'animals', randomize);
@@ -154,9 +154,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.business() // 'http://placeimg.com/640/480/business'
- * faker.image.business(1234, 2345) // 'http://placeimg.com/1234/2345/business'
- * faker.image.business(1234, 2345, true) // 'http://placeimg.com/1234/2345/business?56789'
+ * faker.image.business() // 'http://loremflickr.com/640/480/business'
+ * faker.image.business(1234, 2345) // 'http://loremflickr.com/1234/2345/business'
+ * faker.image.business(1234, 2345, true) // 'http://loremflickr.com/1234/2345/business?56789'
*/
business(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'business', randomize);
@@ -170,9 +170,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.cats() // 'http://placeimg.com/640/480/cats'
- * faker.image.cats(1234, 2345) // 'http://placeimg.com/1234/2345/cats'
- * faker.image.cats(1234, 2345, true) // 'http://placeimg.com/1234/2345/cats?56789'
+ * faker.image.cats() // 'http://loremflickr.com/640/480/cats'
+ * faker.image.cats(1234, 2345) // 'http://loremflickr.com/1234/2345/cats'
+ * faker.image.cats(1234, 2345, true) // 'http://loremflickr.com/1234/2345/cats?56789'
*/
cats(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'cats', randomize);
@@ -186,9 +186,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.city() // 'http://placeimg.com/640/480/city'
- * faker.image.city(1234, 2345) // 'http://placeimg.com/1234/2345/city'
- * faker.image.city(1234, 2345, true) // 'http://placeimg.com/1234/2345/city?56789'
+ * faker.image.city() // 'http://loremflickr.com/640/480/city'
+ * faker.image.city(1234, 2345) // 'http://loremflickr.com/1234/2345/city'
+ * faker.image.city(1234, 2345, true) // 'http://loremflickr.com/1234/2345/city?56789'
*/
city(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'city', randomize);
@@ -202,9 +202,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.food() // 'http://placeimg.com/640/480/food'
- * faker.image.food(1234, 2345) // 'http://placeimg.com/1234/2345/food'
- * faker.image.food(1234, 2345, true) // 'http://placeimg.com/1234/2345/food?56789'
+ * faker.image.food() // 'http://loremflickr.com/640/480/food'
+ * faker.image.food(1234, 2345) // 'http://loremflickr.com/1234/2345/food'
+ * faker.image.food(1234, 2345, true) // 'http://loremflickr.com/1234/2345/food?56789'
*/
food(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'food', randomize);
@@ -218,9 +218,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.nightlife() // 'http://placeimg.com/640/480/nightlife'
- * faker.image.nightlife(1234, 2345) // 'http://placeimg.com/1234/2345/nightlife'
- * faker.image.nightlife(1234, 2345, true) // 'http://placeimg.com/1234/2345/nightlife?56789'
+ * faker.image.nightlife() // 'http://loremflickr.com/640/480/nightlife'
+ * faker.image.nightlife(1234, 2345) // 'http://loremflickr.com/1234/2345/nightlife'
+ * faker.image.nightlife(1234, 2345, true) // 'http://loremflickr.com/1234/2345/nightlife?56789'
*/
nightlife(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'nightlife', randomize);
@@ -234,9 +234,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.fashion() // 'http://placeimg.com/640/480/fashion'
- * faker.image.fashion(1234, 2345) // 'http://placeimg.com/1234/2345/fashion'
- * faker.image.fashion(1234, 2345, true) // 'http://placeimg.com/1234/2345/fashion?56789'
+ * faker.image.fashion() // 'http://loremflickr.com/640/480/fashion'
+ * faker.image.fashion(1234, 2345) // 'http://loremflickr.com/1234/2345/fashion'
+ * faker.image.fashion(1234, 2345, true) // 'http://loremflickr.com/1234/2345/fashion?56789'
*/
fashion(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'fashion', randomize);
@@ -250,9 +250,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.people() // 'http://placeimg.com/640/480/people'
- * faker.image.people(1234, 2345) // 'http://placeimg.com/1234/2345/people'
- * faker.image.people(1234, 2345, true) // 'http://placeimg.com/1234/2345/people?56789'
+ * faker.image.people() // 'http://loremflickr.com/640/480/people'
+ * faker.image.people(1234, 2345) // 'http://loremflickr.com/1234/2345/people'
+ * faker.image.people(1234, 2345, true) // 'http://loremflickr.com/1234/2345/people?56789'
*/
people(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'people', randomize);
@@ -266,9 +266,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.nature() // 'http://placeimg.com/640/480/nature'
- * faker.image.nature(1234, 2345) // 'http://placeimg.com/1234/2345/nature'
- * faker.image.nature(1234, 2345, true) // 'http://placeimg.com/1234/2345/nature?56789'
+ * faker.image.nature() // 'http://loremflickr.com/640/480/nature'
+ * faker.image.nature(1234, 2345) // 'http://loremflickr.com/1234/2345/nature'
+ * faker.image.nature(1234, 2345, true) // 'http://loremflickr.com/1234/2345/nature?56789'
*/
nature(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'nature', randomize);
@@ -282,9 +282,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.sports() // 'http://placeimg.com/640/480/sports'
- * faker.image.sports(1234, 2345) // 'http://placeimg.com/1234/2345/sports'
- * faker.image.sports(1234, 2345, true) // 'http://placeimg.com/1234/2345/sports?56789'
+ * faker.image.sports() // 'http://loremflickr.com/640/480/sports'
+ * faker.image.sports(1234, 2345) // 'http://loremflickr.com/1234/2345/sports'
+ * faker.image.sports(1234, 2345, true) // 'http://loremflickr.com/1234/2345/sports?56789'
*/
sports(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'sports', randomize);
@@ -298,9 +298,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.technics() // 'http://placeimg.com/640/480/technics'
- * faker.image.technics(1234, 2345) // 'http://placeimg.com/1234/2345/technics'
- * faker.image.technics(1234, 2345, true) // 'http://placeimg.com/1234/2345/technics?56789'
+ * faker.image.technics() // 'http://loremflickr.com/640/480/technics'
+ * faker.image.technics(1234, 2345) // 'http://loremflickr.com/1234/2345/technics'
+ * faker.image.technics(1234, 2345, true) // 'http://loremflickr.com/1234/2345/technics?56789'
*/
technics(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'technics', randomize);
@@ -314,9 +314,9 @@ export class Image {
* @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
- * faker.image.transport() // 'http://placeimg.com/640/480/transport'
- * faker.image.transport(1234, 2345) // 'http://placeimg.com/1234/2345/transport'
- * faker.image.transport(1234, 2345, true) // 'http://placeimg.com/1234/2345/transport?56789'
+ * faker.image.transport() // 'http://loremflickr.com/640/480/transport'
+ * faker.image.transport(1234, 2345) // 'http://loremflickr.com/1234/2345/transport'
+ * faker.image.transport(1234, 2345, true) // 'http://loremflickr.com/1234/2345/transport?56789'
*/
transport(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.imageUrl(width, height, 'transport', randomize);
diff --git a/src/image_providers/lorempicsum.ts b/src/image_providers/lorempicsum.ts
index 56553af07a0..9fed741ed5f 100644
--- a/src/image_providers/lorempicsum.ts
+++ b/src/image_providers/lorempicsum.ts
@@ -1,15 +1,19 @@
import type { Faker } from '..';
+/**
+ * Module to generate links to random images on `https://picsum.photos/`.
+ */
+// TODO ST-DDT 2022-03-11: Rename to picsum?
export class LoremPicsum {
constructor(private readonly faker: Faker) {}
/**
- * Search image from unsplash
+ * Generates a new picsum image url.
*
- * @param width
- * @param height
- * @param grayscale
- * @param blur 1-10
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param grayscale Whether to return a grayscale image. Default to `false`.
+ * @param blur The optional level of blur to apply. Supports `1` - `10`.
*/
image(
width?: number,
@@ -21,22 +25,22 @@ export class LoremPicsum {
}
/**
- * Search grayscale image from unsplash
+ * Generates a new picsum image url.
*
- * @param width
- * @param height
- * @param grayscale
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param grayscale Whether to return a grayscale image. Default to `false`.
*/
imageGrayscale(width?: number, height?: number, grayscale?: boolean): string {
return this.imageUrl(width, height, grayscale);
}
/**
- * Search blurred image from unsplash
+ * Generates a new picsum image url.
*
- * @param width
- * @param height
- * @param blur 1-10
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param blur The optional level of blur to apply. Supports `1` - `10`.
*/
imageBlurred(
width?: number,
@@ -47,13 +51,13 @@ export class LoremPicsum {
}
/**
- * Search same random image from unsplash, based on a seed
+ * Generates a new picsum image url.
*
- * @param width
- * @param height
- * @param grayscale
- * @param blur 1-10
- * @param seed
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param grayscale Whether to return a grayscale image. Default to `false`.
+ * @param blur The optional level of blur to apply. Supports `1` - `10`.
+ * @param seed The optional seed to use.
*/
imageRandomSeeded(
width?: number,
@@ -62,24 +66,30 @@ export class LoremPicsum {
blur?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10,
seed?: string
): string {
+ // TODO ST-DDT 2022-03-11: This method does the same as image url, maybe generate a seed, if it is missig?
return this.imageUrl(width, height, grayscale, blur, seed);
}
/**
- * avatar
+ * Returns a random avatar url.
+ *
+ * @example
+ * faker.internet.avatar()
+ * // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
*/
+ // TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with lorempicsum.
avatar(): string {
return this.faker.internet.avatar();
}
/**
- * imageUrl
+ * Generates a new picsum image url.
*
- * @param width
- * @param height
- * @param grayscale
- * @param blur 1-10
- * @param seed
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param grayscale Whether to return a grayscale image. Default to `false`.
+ * @param blur The optional level of blur to apply. Supports `1` - `10`.
+ * @param seed The optional seed to use.
*/
imageUrl(
width?: number,
diff --git a/src/image_providers/lorempixel.ts b/src/image_providers/lorempixel.ts
index 2b7d526300c..310ba45a74b 100644
--- a/src/image_providers/lorempixel.ts
+++ b/src/image_providers/lorempixel.ts
@@ -1,14 +1,17 @@
import type { Faker } from '..';
+/**
+ * Module to generate links to random images on `https://lorempixel.com/`.
+ */
export class Lorempixel {
constructor(private readonly faker: Faker) {}
/**
- * image
+ * Generates a new lorempixel image url for a random supported category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
image(width?: number, height?: number, randomize?: boolean): string {
const categories = [
@@ -34,19 +37,24 @@ export class Lorempixel {
}
/**
- * avatar
+ * Returns a random avatar url.
+ *
+ * @example
+ * faker.internet.avatar()
+ * // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
*/
+ // TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with lorempixel.
avatar(): string {
return this.faker.internet.avatar();
}
/**
- * imageUrl
+ * Generates a new lorempixel image url.
*
- * @param width
- * @param height
- * @param category
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param category The category of the image to generate.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
imageUrl(
width?: number,
@@ -58,7 +66,7 @@ export class Lorempixel {
height = height || 480;
let url = `https://lorempixel.com/${width}/${height}`;
- if (typeof category !== 'undefined') {
+ if (category != null) {
url += '/' + category;
}
@@ -70,11 +78,11 @@ export class Lorempixel {
}
/**
- * abstract
+ * Generates a new lorempixel image url using the "abstract" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
abstract(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -86,11 +94,11 @@ export class Lorempixel {
}
/**
- * animals
+ * Generates a new lorempixel image url using the "animals" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
animals(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -102,11 +110,11 @@ export class Lorempixel {
}
/**
- * business
+ * Generates a new lorempixel image url using the "business" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
business(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -118,11 +126,11 @@ export class Lorempixel {
}
/**
- * cats
+ * Generates a new lorempixel image url using the "cats" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
cats(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -134,11 +142,11 @@ export class Lorempixel {
}
/**
- * city
+ * Generates a new lorempixel image url using the "city" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
city(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -150,11 +158,11 @@ export class Lorempixel {
}
/**
- * food
+ * Generates a new lorempixel image url using the "food" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
food(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -166,11 +174,11 @@ export class Lorempixel {
}
/**
- * nightlife
+ * Generates a new lorempixel image url using the "nightlife" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
nightlife(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -182,11 +190,11 @@ export class Lorempixel {
}
/**
- * fashion
+ * Generates a new lorempixel image url using the "fashion" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
fashion(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -198,11 +206,11 @@ export class Lorempixel {
}
/**
- * people
+ * Generates a new lorempixel image url using the "people" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
people(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -214,11 +222,11 @@ export class Lorempixel {
}
/**
- * nature
+ * Generates a new lorempixel image url using the "nature" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
nature(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -230,11 +238,11 @@ export class Lorempixel {
}
/**
- * sports
+ * Generates a new lorempixel image url using the "sports" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
sports(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -246,11 +254,11 @@ export class Lorempixel {
}
/**
- * technics
+ * Generates a new lorempixel image url using the "technics" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
technics(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
@@ -262,11 +270,11 @@ export class Lorempixel {
}
/**
- * transport
+ * Generates a new lorempixel image url using the "transport" category.
*
- * @param width
- * @param height
- * @param randomize
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to append a seed to the url. Defaults to `false`.
*/
transport(width?: number, height?: number, randomize?: boolean): string {
return this.faker.image.lorempixel.imageUrl(
diff --git a/src/image_providers/unsplash.ts b/src/image_providers/unsplash.ts
index 45fbdd6c527..dd8abd37f10 100644
--- a/src/image_providers/unsplash.ts
+++ b/src/image_providers/unsplash.ts
@@ -1,6 +1,10 @@
import type { Faker } from '..';
+/**
+ * Module to generate links to random images on `https://source.unsplash.com/`.
+ */
export class Unsplash {
+ // TODO ST-DDT 2022-03-11: Remove unused(?) constant
categories = [
'food',
'nature',
@@ -13,30 +17,35 @@ export class Unsplash {
constructor(private readonly faker: Faker) {}
/**
- * Search image from unsplash
+ * Generates a new unsplash image url for a random supported category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
image(width?: number, height?: number, keyword?: string): string {
return this.imageUrl(width, height, undefined, keyword);
}
/**
- * avatar
+ * Returns a random avatar url.
+ *
+ * @example
+ * faker.internet.avatar()
+ * // 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/315.jpg'
*/
+ // TODO ST-DDT 2022-03-11: Deprecate this method as it is duplicate and has nothing to do with unsplash.
avatar(): string {
return this.faker.internet.avatar();
}
/**
- * imageUrl
+ * Generates a new unsplash image url.
*
- * @param width
- * @param height
- * @param category
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param category The category of the image to generate.
+ * @param keyword The image keywords to use.
*/
imageUrl(
width?: number,
@@ -49,16 +58,14 @@ export class Unsplash {
let url = 'https://source.unsplash.com';
- if (typeof category !== 'undefined') {
+ if (category != null) {
url += '/category/' + category;
}
url += `/${width}x${height}`;
- if (typeof keyword !== 'undefined') {
- const keywordFormat = new RegExp(
- '^([A-Za-z0-9].+,[A-Za-z0-9]+)$|^([A-Za-z0-9]+)$'
- );
+ if (keyword != null) {
+ const keywordFormat = /^([A-Za-z0-9].+,[A-Za-z0-9]+)$|^([A-Za-z0-9]+)$/;
if (keywordFormat.test(keyword)) {
url += '?' + keyword;
}
@@ -68,44 +75,44 @@ export class Unsplash {
}
/**
- * food
+ * Generates a new unsplash image url using the "food" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
food(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(width, height, 'food', keyword);
}
/**
- * people
+ * Generates a new unsplash image url using the "people" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
people(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(width, height, 'people', keyword);
}
/**
- * nature
+ * Generates a new unsplash image url using the "nature" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
nature(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(width, height, 'nature', keyword);
}
/**
- * technology
+ * Generates a new unsplash image url using the "technology" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
technology(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(
@@ -117,11 +124,11 @@ export class Unsplash {
}
/**
- * objects
+ * Generates a new unsplash image url using the "objects" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
objects(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(
@@ -133,11 +140,11 @@ export class Unsplash {
}
/**
- * buildings
+ * Generates a new unsplash image url using the "buildings" category.
*
- * @param width
- * @param height
- * @param keyword
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param keyword The image keywords to use.
*/
buildings(width?: number, height?: number, keyword?: string): string {
return this.faker.image.unsplash.imageUrl(
diff --git a/src/index.ts b/src/index.ts
index 0f4b71ba591..984833f5625 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -26,7 +26,10 @@ export type {
VehicleDefinitions,
WordDefinitions,
} from './definitions';
+export { FakerError } from './errors/faker-error';
export type { FakerOptions, UsableLocale, UsedLocales } from './faker';
+export { Gender } from './name';
+export type { GenderType } from './name';
export { Faker };
// since we are requiring the top level of faker, load all locales by default
diff --git a/src/internal/deprecated.ts b/src/internal/deprecated.ts
new file mode 100644
index 00000000000..7f20c24fde5
--- /dev/null
+++ b/src/internal/deprecated.ts
@@ -0,0 +1,29 @@
+/* eslint-disable jsdoc/check-tag-names */
+/* eslint-disable jsdoc/require-param */
+
+/** @internal */
+export interface DeprecatedOptions {
+ deprecated: string;
+ proposed?: string;
+ since?: string;
+ until?: string;
+}
+
+/** @internal */
+export function deprecated(opts: DeprecatedOptions): void {
+ let message = `[@faker-js/faker]: ${opts.deprecated} is deprecated`;
+
+ if (opts.since) {
+ message += ` since ${opts.since}`;
+ }
+
+ if (opts.until) {
+ message += ` and will be removed in ${opts.until}`;
+ }
+
+ if (opts.proposed) {
+ message += `. Please use ${opts.proposed} instead`;
+ }
+
+ console.warn(message + '.');
+}
diff --git a/src/internet.ts b/src/internet.ts
index f80059f90ed..7615607f546 100644
--- a/src/internet.ts
+++ b/src/internet.ts
@@ -1,5 +1,5 @@
import type { Faker } from '.';
-import * as random_ua from './vendor/user-agent';
+import * as random_ua from './utils/user-agent';
/**
* Module to generate internet related entries.
@@ -203,8 +203,18 @@ export class Internet {
* @example
* faker.internet.ip() // '245.108.222.0'
*/
- // TODO @Shinigami92 2022-01-23: Add ipv4 alias
ip(): string {
+ // TODO @Shinigami92 2022-03-21: We may want to return a IPv4 or IPv6 address here in a later major release
+ return this.ipv4();
+ }
+
+ /**
+ * Generates a random IPv4 address.
+ *
+ * @example
+ * faker.internet.ipv4() // '245.108.222.0'
+ */
+ ipv4(): string {
const randNum = () => {
return this.faker.datatype.number(255).toFixed(0);
};
@@ -348,7 +358,8 @@ export class Internet {
*
* @param len The length of the password to generate. Defaults to `15`.
* @param memorable Whether the generated password should be memorable. Defaults to `false`.
- * @param pattern The pattern that all chars should match should match. Defaults to `/\w/`.
+ * @param pattern The pattern that all chars should match should match.
+ * This option will be ignored, if `memorable` is `true`. Defaults to `/\w/`.
* @param prefix The prefix to use. Defaults to `''`.
*
* @example
@@ -359,15 +370,11 @@ export class Internet {
* faker.internet.password(20, true, /[A-Z]/, 'Hello ') // 'Hello IREOXTDWPERQSB'
*/
password(
- len?: number,
- memorable?: boolean,
- pattern?: RegExp,
- prefix?: string
+ len: number = 15,
+ memorable: boolean = false,
+ pattern: RegExp = /\w/,
+ prefix: string = ''
): string {
- len = len || 15;
- if (typeof memorable === 'undefined') {
- memorable = false;
- }
/*
* password-generator ( function )
* Copyright(c) 2011-2013 Bermi Ferrer
@@ -376,12 +383,11 @@ export class Internet {
const vowel = /[aeiouAEIOU]$/;
const consonant = /[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$/;
const _password = (
- length = 10,
- memorable = true,
- pattern = /\w/,
- prefix = ''
+ length: number,
+ memorable: boolean,
+ pattern: RegExp,
+ prefix: string
): string => {
- let char: string;
if (prefix.length >= length) {
return prefix;
}
@@ -393,14 +399,14 @@ export class Internet {
}
}
const n = this.faker.datatype.number(94) + 33;
- char = String.fromCharCode(n);
+ let char = String.fromCharCode(n);
if (memorable) {
char = char.toLowerCase();
}
if (!char.match(pattern)) {
return _password(length, memorable, pattern, prefix);
}
- return _password(length, memorable, pattern, '' + prefix + char);
+ return _password(length, memorable, pattern, prefix + char);
};
return _password(len, memorable, pattern, prefix);
}
diff --git a/src/locales/ar/address/index.ts b/src/locales/ar/address/index.ts
index 4506fbc8c84..7789c0e5f5b 100644
--- a/src/locales/ar/address/index.ts
+++ b/src/locales/ar/address/index.ts
@@ -9,7 +9,6 @@ import city_name from './city_name';
import country from './country';
import default_country from './default_country';
import postcode from './postcode';
-import postcode_by_state from './postcode_by_state';
import secondary_address from './secondary_address';
import state from './state';
import street_address from './street_address';
@@ -23,7 +22,6 @@ const address = {
country,
default_country,
postcode,
- postcode_by_state,
secondary_address,
state,
street_address,
diff --git a/src/locales/ar/address/postcode_by_state.ts b/src/locales/ar/address/postcode_by_state.ts
deleted file mode 100644
index 4433f068b5e..00000000000
--- a/src/locales/ar/address/postcode_by_state.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['#####', '#####-####'];
diff --git a/src/locales/ar/address/street_address.ts b/src/locales/ar/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/ar/address/street_address.ts
+++ b/src/locales/ar/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ar/name/female_first_name.ts b/src/locales/ar/name/female_first_name.ts
new file mode 100644
index 00000000000..85d256def40
--- /dev/null
+++ b/src/locales/ar/name/female_first_name.ts
@@ -0,0 +1,13 @@
+export default [
+ 'فاطمه',
+ 'خلود',
+ 'عوضية',
+ 'عنود',
+ 'عنود',
+ 'نوف',
+ 'ريم',
+ 'اروي',
+ 'براءة',
+ 'بتول',
+ 'بلسم',
+];
diff --git a/src/locales/ar/name/index.ts b/src/locales/ar/name/index.ts
index 77b4c2eb216..b8cd692accc 100644
--- a/src/locales/ar/name/index.ts
+++ b/src/locales/ar/name/index.ts
@@ -3,17 +3,23 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { NameDefinitions } from '../../..';
+import female_first_name from './female_first_name';
import first_name from './first_name';
import last_name from './last_name';
+import male_first_name from './male_first_name';
import name_ from './name';
import prefix from './prefix';
+import suffix from './suffix';
import title from './title';
const name: Partial = {
+ female_first_name,
first_name,
last_name,
+ male_first_name,
name: name_,
prefix,
+ suffix,
title,
};
diff --git a/src/locales/ar/name/male_first_name.ts b/src/locales/ar/name/male_first_name.ts
new file mode 100644
index 00000000000..d8652135b13
--- /dev/null
+++ b/src/locales/ar/name/male_first_name.ts
@@ -0,0 +1,12 @@
+export default [
+ 'محمد',
+ 'أحمد',
+ 'حسن',
+ 'خالد',
+ 'محسن',
+ 'على',
+ 'ابراهيم',
+ 'كمال',
+ 'عبد الله',
+ 'مصعب',
+];
diff --git a/src/locales/ar/name/suffix.ts b/src/locales/ar/name/suffix.ts
new file mode 100644
index 00000000000..eebfcb859b6
--- /dev/null
+++ b/src/locales/ar/name/suffix.ts
@@ -0,0 +1 @@
+export default ['المحترم', 'المبجل', 'حفظه الله', 'الموقر'];
diff --git a/src/locales/az/address/street_address.ts b/src/locales/az/address/street_address.ts
index a6c7cff8a2d..73037a5c55f 100644
--- a/src/locales/az/address/street_address.ts
+++ b/src/locales/az/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}, #{building_number}'];
+export default {
+ normal: '{{address.streetName}}, {{address.buildingNumber}}',
+ full: '{{address.streetName}}, {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/cz/address/street_address.ts b/src/locales/cz/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/cz/address/street_address.ts
+++ b/src/locales/cz/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/de/address/street_address.ts b/src/locales/de/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/de/address/street_address.ts
+++ b/src/locales/de/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/de_AT/address/street_address.ts b/src/locales/de_AT/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/de_AT/address/street_address.ts
+++ b/src/locales/de_AT/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/en/address/city_prefix.ts b/src/locales/en/address/city_prefix.ts
index 6a87806239a..1b76009ea9f 100644
--- a/src/locales/en/address/city_prefix.ts
+++ b/src/locales/en/address/city_prefix.ts
@@ -1 +1,10 @@
-export default ['North', 'East', 'West', 'South', 'New', 'Lake', 'Port'];
+export default [
+ 'North',
+ 'East',
+ 'West',
+ 'South',
+ 'New',
+ 'Lake',
+ 'Port',
+ 'Fort',
+];
diff --git a/src/locales/en/address/city_suffix.ts b/src/locales/en/address/city_suffix.ts
index 24ed8b3849d..40769ad5421 100644
--- a/src/locales/en/address/city_suffix.ts
+++ b/src/locales/en/address/city_suffix.ts
@@ -5,17 +5,22 @@ export default [
'ville',
'berg',
'burgh',
+ 'boro',
'borough',
'bury',
'view',
'port',
'mouth',
'stad',
+ 'stead',
'furt',
'chester',
+ 'cester',
'mouth',
'fort',
+ 'field',
'haven',
'side',
'shire',
+ 'worth',
];
diff --git a/src/locales/en/address/index.ts b/src/locales/en/address/index.ts
index efb55311d33..78cb3ec842c 100644
--- a/src/locales/en/address/index.ts
+++ b/src/locales/en/address/index.ts
@@ -16,7 +16,6 @@ import default_country from './default_country';
import direction from './direction';
import direction_abbr from './direction_abbr';
import postcode from './postcode';
-import postcode_by_state from './postcode_by_state';
import secondary_address from './secondary_address';
import state from './state';
import state_abbr from './state_abbr';
@@ -39,7 +38,6 @@ const address = {
direction,
direction_abbr,
postcode,
- postcode_by_state,
secondary_address,
state,
state_abbr,
diff --git a/src/locales/en/address/postcode_by_state.ts b/src/locales/en/address/postcode_by_state.ts
deleted file mode 100644
index 4433f068b5e..00000000000
--- a/src/locales/en/address/postcode_by_state.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['#####', '#####-####'];
diff --git a/src/locales/en/address/street_address.ts b/src/locales/en/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/en/address/street_address.ts
+++ b/src/locales/en/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/en/commerce/product_name.ts b/src/locales/en/commerce/product_name.ts
index 9658530e97c..8c52af68d1d 100644
--- a/src/locales/en/commerce/product_name.ts
+++ b/src/locales/en/commerce/product_name.ts
@@ -2,24 +2,32 @@ export default {
adjective: [
'Small',
'Ergonomic',
+ 'Electronic',
'Rustic',
'Intelligent',
'Gorgeous',
'Incredible',
+ 'Elegant',
'Fantastic',
'Practical',
+ 'Modern',
+ 'Recycled',
'Sleek',
+ 'Bespoke',
'Awesome',
'Generic',
'Handcrafted',
'Handmade',
+ 'Oriental',
'Licensed',
+ 'Luxurious',
'Refined',
'Unbranded',
'Tasty',
],
material: [
'Steel',
+ 'Bronze',
'Wooden',
'Concrete',
'Plastic',
diff --git a/src/locales/en/name/female_middle_name.ts b/src/locales/en/name/female_middle_name.ts
new file mode 100644
index 00000000000..02a892fdccf
--- /dev/null
+++ b/src/locales/en/name/female_middle_name.ts
@@ -0,0 +1,212 @@
+export default [
+ 'Abigail',
+ 'Adele',
+ 'Alex',
+ 'Alice',
+ 'Alisha',
+ 'Amber',
+ 'Amelia',
+ 'Amora',
+ 'Anaïs',
+ 'Angelou',
+ 'Anika',
+ 'Anise',
+ 'Annabel',
+ 'Anne',
+ 'Aphrodite',
+ 'Aretha',
+ 'Arya',
+ 'Ashton',
+ 'Aster',
+ 'Audrey',
+ 'Avery',
+ 'Bailee',
+ 'Bay',
+ 'Belle',
+ 'Beth',
+ 'Billie',
+ 'Blair',
+ 'Blaise',
+ 'Blake',
+ 'Blanche',
+ 'Blue',
+ 'Bree',
+ 'Brielle',
+ 'Brienne',
+ 'Brooke',
+ 'Caleen',
+ 'Candice',
+ 'Caprice',
+ 'Carelyn',
+ 'Caylen',
+ 'Celine',
+ 'Cerise',
+ 'Cia',
+ 'Claire',
+ 'Claudia',
+ 'Clementine',
+ 'Coral',
+ 'Coraline',
+ 'Dahlia',
+ 'Dakota',
+ 'Dawn',
+ 'Della',
+ 'Demi',
+ 'Denise',
+ 'Denver',
+ 'Devine',
+ 'Devon',
+ 'Diana',
+ 'Dylan',
+ 'Ebony',
+ 'Eden',
+ 'Eleanor',
+ 'Elein',
+ 'Elizabeth',
+ 'Ellen',
+ 'Elodie',
+ 'Eloise',
+ 'Ember',
+ 'Emma',
+ 'Erin',
+ 'Eyre',
+ 'Faith',
+ 'Farrah',
+ 'Fawn',
+ 'Fayre',
+ 'Fern',
+ 'France',
+ 'Francis',
+ 'Frida',
+ 'Genisis',
+ 'Georgia',
+ 'Grace',
+ 'Gwen',
+ 'Harley',
+ 'Harper',
+ 'Hazel',
+ 'Helen',
+ 'Hippolyta',
+ 'Holly',
+ 'Hope',
+ 'Imani',
+ 'Iowa',
+ 'Ireland',
+ 'Irene',
+ 'Iris',
+ 'Isa',
+ 'Isla',
+ 'Ivy',
+ 'Jade',
+ 'Jane',
+ 'Jazz',
+ 'Jean',
+ 'Jess',
+ 'Jett',
+ 'Jo',
+ 'Joan',
+ 'Jolie',
+ 'Jordan',
+ 'Josie',
+ 'Journey',
+ 'Joy',
+ 'Jules',
+ 'Julien',
+ 'Juliet',
+ 'Juniper',
+ 'Justice',
+ 'Kali',
+ 'Karma',
+ 'Kat',
+ 'Kate',
+ 'Kennedy',
+ 'Keva',
+ 'Kylie',
+ 'Lake',
+ 'Lane',
+ 'Lark',
+ 'Layla',
+ 'Lee',
+ 'Leigh',
+ 'Leona',
+ 'Lexi',
+ 'London',
+ 'Lou',
+ 'Louise',
+ 'Love',
+ 'Luna',
+ 'Lux',
+ 'Lynn',
+ 'Lyric',
+ 'Maddie',
+ 'Mae',
+ 'Marie',
+ 'Matilda',
+ 'Maude',
+ 'Maybel',
+ 'Meadow',
+ 'Medusa',
+ 'Mercy',
+ 'Michelle',
+ 'Mirabel',
+ 'Monroe',
+ 'Morgan',
+ 'Nalia',
+ 'Naomi',
+ 'Nova',
+ 'Olive',
+ 'Paige',
+ 'Parker',
+ 'Pax',
+ 'Pearl',
+ 'Penelope',
+ 'Phoenix',
+ 'Quinn',
+ 'Rae',
+ 'Rain',
+ 'Raven',
+ 'Ray',
+ 'Raye',
+ 'Rebel',
+ 'Reese',
+ 'Reeve',
+ 'Regan',
+ 'Riley',
+ 'River',
+ 'Robin',
+ 'Rory',
+ 'Rose',
+ 'Royal',
+ 'Ruth',
+ 'Rylie',
+ 'Sage',
+ 'Sam',
+ 'Saturn',
+ 'Scout',
+ 'Serena',
+ 'Sky',
+ 'Skylar',
+ 'Sofia',
+ 'Sophia',
+ 'Storm',
+ 'Sue',
+ 'Suzanne',
+ 'Sydney',
+ 'Taylen',
+ 'Taylor',
+ 'Teagan',
+ 'Tempest',
+ 'Tenley',
+ 'Thea',
+ 'Trinity',
+ 'Valerie',
+ 'Venus',
+ 'Vera',
+ 'Violet',
+ 'Willow',
+ 'Winter',
+ 'Xena',
+ 'Zaylee',
+ 'Zion',
+ 'Zoe',
+];
diff --git a/src/locales/en/name/index.ts b/src/locales/en/name/index.ts
index 39f195db94d..dcc3fef143a 100644
--- a/src/locales/en/name/index.ts
+++ b/src/locales/en/name/index.ts
@@ -5,10 +5,13 @@
import type { NameDefinitions } from '../../..';
import binary_gender from './binary_gender';
import female_first_name from './female_first_name';
+import female_middle_name from './female_middle_name';
import first_name from './first_name';
import gender from './gender';
import last_name from './last_name';
import male_first_name from './male_first_name';
+import male_middle_name from './male_middle_name';
+import middle_name from './middle_name';
import name_ from './name';
import prefix from './prefix';
import suffix from './suffix';
@@ -17,10 +20,13 @@ import title from './title';
const name: Partial = {
binary_gender,
female_first_name,
+ female_middle_name,
first_name,
gender,
last_name,
male_first_name,
+ male_middle_name,
+ middle_name,
name: name_,
prefix,
suffix,
diff --git a/src/locales/en/name/male_middle_name.ts b/src/locales/en/name/male_middle_name.ts
new file mode 100644
index 00000000000..6bd3ac848ba
--- /dev/null
+++ b/src/locales/en/name/male_middle_name.ts
@@ -0,0 +1,100 @@
+export default [
+ 'Ace',
+ 'Aiden',
+ 'Alexander',
+ 'Ander',
+ 'Anthony',
+ 'Asher',
+ 'August',
+ 'Aziel',
+ 'Bear',
+ 'Beckham',
+ 'Benjamin',
+ 'Buddy',
+ 'Calvin',
+ 'Carter',
+ 'Charles',
+ 'Christopher',
+ 'Clyde',
+ 'Cooper',
+ 'Daniel',
+ 'David',
+ 'Dior',
+ 'Dylan',
+ 'Elijah',
+ 'Ellis',
+ 'Emerson',
+ 'Ethan',
+ 'Ezra',
+ 'Fletcher',
+ 'Flynn',
+ 'Gabriel',
+ 'Grayson',
+ 'Gus',
+ 'Hank',
+ 'Harrison',
+ 'Hendrix',
+ 'Henry',
+ 'Houston',
+ 'Hudson',
+ 'Hugh',
+ 'Isaac',
+ 'Jack',
+ 'Jackson',
+ 'Jacob',
+ 'Jakobe',
+ 'James',
+ 'Jaxon',
+ 'Jaxtyn',
+ 'Jayden',
+ 'John',
+ 'Joseph',
+ 'Josiah',
+ 'Jude',
+ 'Julian',
+ 'Karsyn',
+ 'Kenji',
+ 'Kobe',
+ 'Kylo',
+ 'Lennon',
+ 'Leo',
+ 'Levi',
+ 'Liam',
+ 'Lincoln',
+ 'Logan',
+ 'Louis',
+ 'Lucas',
+ 'Lucky',
+ 'Luke',
+ 'Mason',
+ 'Mateo',
+ 'Matthew',
+ 'Maverick',
+ 'Michael',
+ 'Monroe',
+ 'Nixon',
+ 'Ocean',
+ 'Oliver',
+ 'Otis',
+ 'Otto',
+ 'Owen',
+ 'Ozzy',
+ 'Parker',
+ 'Rocky',
+ 'Samuel',
+ 'Sebastian',
+ 'Sonny',
+ 'Teddy',
+ 'Theo',
+ 'Theodore',
+ 'Thomas',
+ 'Truett',
+ 'Walter',
+ 'Warren',
+ 'Watson',
+ 'William',
+ 'Wison',
+ 'Wyatt',
+ 'Ziggy',
+ 'Zyair',
+];
diff --git a/src/locales/en/name/middle_name.ts b/src/locales/en/name/middle_name.ts
new file mode 100644
index 00000000000..0f03c1535dc
--- /dev/null
+++ b/src/locales/en/name/middle_name.ts
@@ -0,0 +1,64 @@
+export default [
+ 'Addison',
+ 'Alex',
+ 'Anderson',
+ 'Angel',
+ 'Arden',
+ 'August',
+ 'Austin',
+ 'Avery',
+ 'Bailey',
+ 'Billie',
+ 'Blake',
+ 'Bowie',
+ 'Brooklyn',
+ 'Cameron',
+ 'Charlie',
+ 'Corey',
+ 'Dakota',
+ 'Drew',
+ 'Elliott',
+ 'Ellis',
+ 'Emerson',
+ 'Finley',
+ 'Gray',
+ 'Greer',
+ 'Harper',
+ 'Hayden',
+ 'Jaden',
+ 'James',
+ 'Jamie',
+ 'Jordan',
+ 'Jules',
+ 'Kai',
+ 'Kendall',
+ 'Kennedy',
+ 'Kyle',
+ 'Leslie',
+ 'Logan',
+ 'London',
+ 'Marlowe',
+ 'Micah',
+ 'Nico',
+ 'Noah',
+ 'North',
+ 'Parker',
+ 'Phoenix',
+ 'Quinn',
+ 'Reagan',
+ 'Reese',
+ 'Reign',
+ 'Riley',
+ 'River',
+ 'Robin',
+ 'Rory',
+ 'Rowan',
+ 'Ryan',
+ 'Sage',
+ 'Sasha',
+ 'Sawyer',
+ 'Shawn',
+ 'Shiloh',
+ 'Skyler',
+ 'Taylor',
+];
diff --git a/src/locales/en_GB/internet/domain_suffix.ts b/src/locales/en_GB/internet/domain_suffix.ts
index 4ef54a67512..d6de8904c55 100644
--- a/src/locales/en_GB/internet/domain_suffix.ts
+++ b/src/locales/en_GB/internet/domain_suffix.ts
@@ -1 +1,21 @@
-export default ['co.uk', 'com', 'biz', 'info', 'name'];
+export default [
+ 'ac.uk',
+ 'biz',
+ 'co',
+ 'co.uk',
+ 'com',
+ 'cymru',
+ 'gov.uk',
+ 'info',
+ 'london',
+ 'ltd.uk',
+ 'me.uk',
+ 'name',
+ 'nhs.uk',
+ 'org.uk',
+ 'plc.uk',
+ 'sch.uk',
+ 'scot',
+ 'uk',
+ 'wales',
+];
diff --git a/src/locales/en_GH/address/street_address.ts b/src/locales/en_GH/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/en_GH/address/street_address.ts
+++ b/src/locales/en_GH/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/en_IND/name/last_name.ts b/src/locales/en_IND/name/last_name.ts
index f636a5c68ff..01913363868 100644
--- a/src/locales/en_IND/name/last_name.ts
+++ b/src/locales/en_IND/name/last_name.ts
@@ -13,6 +13,7 @@ export default [
'Bharadwaj',
'Bhat',
'Butt',
+ 'Bhadresha',
'Bhattacharya',
'Bhattathiri',
'Chaturvedi',
@@ -36,6 +37,7 @@ export default [
'Iyer',
'Iyengar',
'Jain',
+ 'Jangid',
'Jha',
'Johar',
'Joshi',
@@ -80,6 +82,7 @@ export default [
'Singh',
'Sinha',
'Somayaji',
+ 'Suthar',
'Tagore',
'Talwar',
'Tandon',
diff --git a/src/locales/es/address/street_address.ts b/src/locales/es/address/street_address.ts
index b313d432161..36449d0b2e1 100644
--- a/src/locales/es/address/street_address.ts
+++ b/src/locales/es/address/street_address.ts
@@ -1,4 +1,4 @@
-export default [
- '#{street_name}#{building_number}',
- '#{street_name}#{building_number} #{secondary_address}',
-];
+export default {
+ normal: '{{address.streetName}}{{address.buildingNumber}}',
+ full: '{{address.streetName}}{{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/es_MX/address/street_address.ts b/src/locales/es_MX/address/street_address.ts
index b313d432161..36449d0b2e1 100644
--- a/src/locales/es_MX/address/street_address.ts
+++ b/src/locales/es_MX/address/street_address.ts
@@ -1,4 +1,4 @@
-export default [
- '#{street_name}#{building_number}',
- '#{street_name}#{building_number} #{secondary_address}',
-];
+export default {
+ normal: '{{address.streetName}}{{address.buildingNumber}}',
+ full: '{{address.streetName}}{{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/fa/address/country_code.ts b/src/locales/fa/address/country_code.ts
deleted file mode 100644
index 8aa39c2ffaa..00000000000
--- a/src/locales/fa/address/country_code.ts
+++ /dev/null
@@ -1,252 +0,0 @@
-export default [
- 'AD',
- 'AE',
- 'AF',
- 'AG',
- 'AI',
- 'AL',
- 'AM',
- 'AO',
- 'AQ',
- 'AR',
- 'AS',
- 'AT',
- 'AU',
- 'AW',
- 'AX',
- 'AZ',
- 'BA',
- 'BB',
- 'BD',
- 'BE',
- 'BF',
- 'BG',
- 'BH',
- 'BI',
- 'BJ',
- 'BL',
- 'BM',
- 'BN',
- 'BO',
- 'BQ',
- 'BQ',
- 'BR',
- 'BS',
- 'BT',
- 'BV',
- 'BW',
- 'BY',
- 'BZ',
- 'CA',
- 'CC',
- 'CD',
- 'CF',
- 'CG',
- 'CH',
- 'CI',
- 'CK',
- 'CL',
- 'CM',
- 'CN',
- 'CO',
- 'CR',
- 'CU',
- 'CV',
- 'CW',
- 'CX',
- 'CY',
- 'CZ',
- 'DE',
- 'DJ',
- 'DK',
- 'DM',
- 'DO',
- 'DZ',
- 'EC',
- 'EE',
- 'EG',
- 'EH',
- 'ER',
- 'ES',
- 'ET',
- 'FI',
- 'FJ',
- 'FK',
- 'FM',
- 'FO',
- 'FR',
- 'GA',
- 'GB',
- 'GD',
- 'GE',
- 'GF',
- 'GG',
- 'GH',
- 'GI',
- 'GL',
- 'GM',
- 'GN',
- 'GP',
- 'GQ',
- 'GR',
- 'GS',
- 'GT',
- 'GU',
- 'GW',
- 'GY',
- 'HK',
- 'HM',
- 'HN',
- 'HR',
- 'HT',
- 'HU',
- 'ID',
- 'IE',
- 'IL',
- 'IM',
- 'IN',
- 'IO',
- 'IQ',
- 'IR',
- 'IS',
- 'IT',
- 'JE',
- 'JM',
- 'JO',
- 'JP',
- 'KE',
- 'KG',
- 'KH',
- 'KI',
- 'KM',
- 'KN',
- 'KP',
- 'KR',
- 'KW',
- 'KY',
- 'KZ',
- 'LA',
- 'LB',
- 'LC',
- 'LI',
- 'LK',
- 'LR',
- 'LS',
- 'LT',
- 'LU',
- 'LV',
- 'LY',
- 'MA',
- 'MC',
- 'MD',
- 'ME',
- 'MF',
- 'MG',
- 'MH',
- 'MK',
- 'ML',
- 'MM',
- 'MN',
- 'MO',
- 'MP',
- 'MQ',
- 'MR',
- 'MS',
- 'MT',
- 'MU',
- 'MV',
- 'MW',
- 'MX',
- 'MY',
- 'MZ',
- 'NA',
- 'NC',
- 'NE',
- 'NF',
- 'NG',
- 'NI',
- 'NL',
- 'NO',
- 'NP',
- 'NR',
- 'NU',
- 'NZ',
- 'OM',
- 'PA',
- 'PE',
- 'PF',
- 'PG',
- 'PH',
- 'PK',
- 'PL',
- 'PM',
- 'PN',
- 'PR',
- 'PS',
- 'PT',
- 'PW',
- 'PY',
- 'QA',
- 'RE',
- 'RO',
- 'RS',
- 'RU',
- 'RW',
- 'SA',
- 'SB',
- 'SC',
- 'SD',
- 'SE',
- 'SG',
- 'SH',
- 'SI',
- 'SJ',
- 'SK',
- 'SL',
- 'SM',
- 'SN',
- 'SO',
- 'SR',
- 'SS',
- 'ST',
- 'SV',
- 'SX',
- 'SY',
- 'SZ',
- 'TC',
- 'TD',
- 'TF',
- 'TG',
- 'TH',
- 'TJ',
- 'TK',
- 'TL',
- 'TM',
- 'TN',
- 'TO',
- 'TR',
- 'TT',
- 'TV',
- 'TW',
- 'TZ',
- 'UA',
- 'UG',
- 'UM',
- 'US',
- 'UY',
- 'UZ',
- 'VA',
- 'VC',
- 'VE',
- 'VG',
- 'VI',
- 'VN',
- 'VU',
- 'WF',
- 'WS',
- 'YE',
- 'YT',
- 'ZA',
- 'ZM',
- 'ZW',
-];
diff --git a/src/locales/fa/address/index.ts b/src/locales/fa/address/index.ts
index 1db7305e731..64b49f9847b 100644
--- a/src/locales/fa/address/index.ts
+++ b/src/locales/fa/address/index.ts
@@ -9,7 +9,6 @@ import city_name from './city_name';
import city_prefix from './city_prefix';
import city_suffix from './city_suffix';
import country from './country';
-import country_code from './country_code';
import default_country from './default_country';
import direction from './direction';
import postcode from './postcode';
@@ -27,7 +26,6 @@ const address = {
city_prefix,
city_suffix,
country,
- country_code,
default_country,
direction,
postcode,
diff --git a/src/locales/fa/address/street_address.ts b/src/locales/fa/address/street_address.ts
index 22ab96e3e01..74133d4015a 100644
--- a/src/locales/fa/address/street_address.ts
+++ b/src/locales/fa/address/street_address.ts
@@ -1,4 +1,4 @@
-export default [
- '#{street_name}, پلاک #{building_number}',
- '#{street_name}, #{street_name}, پلاک #{building_number}',
-];
+export default {
+ normal: '{{address.streetName}}, پلاک {{address.buildingNumber}}',
+ full: '{{address.streetName}}, پلاک {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/fr/address/street_address.ts b/src/locales/fr/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/fr/address/street_address.ts
+++ b/src/locales/fr/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/fr_BE/address/street_address.ts b/src/locales/fr_BE/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/fr_BE/address/street_address.ts
+++ b/src/locales/fr_BE/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ge/address/street_address.ts b/src/locales/ge/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/ge/address/street_address.ts
+++ b/src/locales/ge/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/he/address/country_code.ts b/src/locales/he/address/country_code.ts
deleted file mode 100644
index 1c4f017e663..00000000000
--- a/src/locales/he/address/country_code.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default [''];
diff --git a/src/locales/he/address/country_code_alpha_3.ts b/src/locales/he/address/country_code_alpha_3.ts
deleted file mode 100644
index 20708d640bd..00000000000
--- a/src/locales/he/address/country_code_alpha_3.ts
+++ /dev/null
@@ -1,252 +0,0 @@
-export default [
- 'BGD',
- 'BEL',
- 'BFA',
- 'BGR',
- 'BIH',
- 'BRB',
- 'WLF',
- 'BLM',
- 'BMU',
- 'BRN',
- 'BOL',
- 'BHR',
- 'BDI',
- 'BEN',
- 'BTN',
- 'JAM',
- 'BVT',
- 'BWA',
- 'WSM',
- 'BES',
- 'BRA',
- 'BHS',
- 'JEY',
- 'BLR',
- 'BLZ',
- 'RUS',
- 'RWA',
- 'SRB',
- 'TLS',
- 'REU',
- 'TKM',
- 'TJK',
- 'ROU',
- 'TKL',
- 'GNB',
- 'GUM',
- 'GTM',
- 'SGS',
- 'GRC',
- 'GNQ',
- 'GLP',
- 'JPN',
- 'GUY',
- 'GGY',
- 'GUF',
- 'GEO',
- 'GRD',
- 'GBR',
- 'GAB',
- 'SLV',
- 'GIN',
- 'GMB',
- 'GRL',
- 'GIB',
- 'GHA',
- 'OMN',
- 'TUN',
- 'JOR',
- 'HRV',
- 'HTI',
- 'HUN',
- 'HKG',
- 'HND',
- 'HMD',
- 'VEN',
- 'PRI',
- 'PSE',
- 'PLW',
- 'PRT',
- 'SJM',
- 'PRY',
- 'IRQ',
- 'PAN',
- 'PYF',
- 'PNG',
- 'PER',
- 'PAK',
- 'PHL',
- 'PCN',
- 'POL',
- 'SPM',
- 'ZMB',
- 'ESH',
- 'EST',
- 'EGY',
- 'ZAF',
- 'ECU',
- 'ITA',
- 'VNM',
- 'SLB',
- 'ETH',
- 'SOM',
- 'ZWE',
- 'SAU',
- 'ESP',
- 'ERI',
- 'MNE',
- 'MDA',
- 'MDG',
- 'MAF',
- 'MAR',
- 'MCO',
- 'UZB',
- 'MMR',
- 'MLI',
- 'MAC',
- 'MNG',
- 'MHL',
- 'MKD',
- 'MUS',
- 'MLT',
- 'MWI',
- 'MDV',
- 'MTQ',
- 'MNP',
- 'MSR',
- 'MRT',
- 'IMN',
- 'UGA',
- 'TZA',
- 'MYS',
- 'MEX',
- 'ISR',
- 'FRA',
- 'IOT',
- 'SHN',
- 'FIN',
- 'FJI',
- 'FLK',
- 'FSM',
- 'FRO',
- 'NIC',
- 'NLD',
- 'NOR',
- 'NAM',
- 'VUT',
- 'NCL',
- 'NER',
- 'NFK',
- 'NGA',
- 'NZL',
- 'NPL',
- 'NRU',
- 'NIU',
- 'COK',
- 'XKX',
- 'CIV',
- 'CHE',
- 'COL',
- 'CHN',
- 'CMR',
- 'CHL',
- 'CCK',
- 'CAN',
- 'COG',
- 'CAF',
- 'COD',
- 'CZE',
- 'CYP',
- 'CXR',
- 'CRI',
- 'CUW',
- 'CPV',
- 'CUB',
- 'SWZ',
- 'SYR',
- 'SXM',
- 'KGZ',
- 'KEN',
- 'SSD',
- 'SUR',
- 'KIR',
- 'KHM',
- 'KNA',
- 'COM',
- 'STP',
- 'SVK',
- 'KOR',
- 'SVN',
- 'PRK',
- 'KWT',
- 'SEN',
- 'SMR',
- 'SLE',
- 'SYC',
- 'KAZ',
- 'CYM',
- 'SGP',
- 'SWE',
- 'SDN',
- 'DOM',
- 'DMA',
- 'DJI',
- 'DNK',
- 'VGB',
- 'DEU',
- 'YEM',
- 'DZA',
- 'USA',
- 'URY',
- 'MYT',
- 'UMI',
- 'LBN',
- 'LCA',
- 'LAO',
- 'TUV',
- 'TWN',
- 'TTO',
- 'TUR',
- 'LKA',
- 'LIE',
- 'LVA',
- 'TON',
- 'LTU',
- 'LUX',
- 'LBR',
- 'LSO',
- 'THA',
- 'ATF',
- 'TGO',
- 'TCD',
- 'TCA',
- 'LBY',
- 'VAT',
- 'VCT',
- 'ARE',
- 'AND',
- 'ATG',
- 'AFG',
- 'AIA',
- 'VIR',
- 'ISL',
- 'IRN',
- 'ARM',
- 'ALB',
- 'AGO',
- 'ATA',
- 'ASM',
- 'ARG',
- 'AUS',
- 'AUT',
- 'ABW',
- 'IND',
- 'ALA',
- 'AZE',
- 'IRL',
- 'IDN',
- 'UKR',
- 'QAT',
- 'MOZ',
-];
diff --git a/src/locales/he/address/index.ts b/src/locales/he/address/index.ts
index b5c5cf38310..bcf2af271c3 100644
--- a/src/locales/he/address/index.ts
+++ b/src/locales/he/address/index.ts
@@ -8,14 +8,11 @@ import city from './city';
import city_prefix from './city_prefix';
import city_suffix from './city_suffix';
import country from './country';
-import country_code from './country_code';
-import country_code_alpha_3 from './country_code_alpha_3';
import county from './county';
import default_country from './default_country';
import direction from './direction';
import direction_abbr from './direction_abbr';
import postcode from './postcode';
-import postcode_by_state from './postcode_by_state';
import secondary_address from './secondary_address';
import state from './state';
import state_abbr from './state_abbr';
@@ -30,14 +27,11 @@ const address = {
city_prefix,
city_suffix,
country,
- country_code,
- country_code_alpha_3,
county,
default_country,
direction,
direction_abbr,
postcode,
- postcode_by_state,
secondary_address,
state,
state_abbr,
diff --git a/src/locales/he/address/postcode_by_state.ts b/src/locales/he/address/postcode_by_state.ts
deleted file mode 100644
index 2850dba4057..00000000000
--- a/src/locales/he/address/postcode_by_state.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['#####', '#######'];
diff --git a/src/locales/he/address/street_address.ts b/src/locales/he/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/he/address/street_address.ts
+++ b/src/locales/he/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/hr/address/street_address.ts b/src/locales/hr/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/hr/address/street_address.ts
+++ b/src/locales/hr/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/hy/address/street_address.ts b/src/locales/hy/address/street_address.ts
index 41ed0474025..aaf5810e3a4 100644
--- a/src/locales/hy/address/street_address.ts
+++ b/src/locales/hy/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{address.street_name} #{address.building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/id_ID/address/street_address.ts b/src/locales/id_ID/address/street_address.ts
index 33d2e0ce565..1a4028a2498 100644
--- a/src/locales/id_ID/address/street_address.ts
+++ b/src/locales/id_ID/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} no #{building_number}'];
+export default {
+ normal: '{{address.streetName}} no {{address.buildingNumber}}',
+ full: '{{address.streetName}} no {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/it/address/street_address.ts b/src/locales/it/address/street_address.ts
index 98c792d0608..fc1a70df4b5 100644
--- a/src/locales/it/address/street_address.ts
+++ b/src/locales/it/address/street_address.ts
@@ -1,4 +1,4 @@
-export default [
- '#{street_name} #{building_number}',
- '#{street_name} #{building_number}, #{secondary_address}',
-];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}}, {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ko/address/city_name.ts b/src/locales/ko/address/city_name.ts
index 044e6bb3ffd..c90b09c02e3 100644
--- a/src/locales/ko/address/city_name.ts
+++ b/src/locales/ko/address/city_name.ts
@@ -27,4 +27,11 @@ export default [
'부평',
'강화',
'수성',
+ '수원',
+ '속초',
+ '전주',
+ '목포',
+ '분당',
+ '안양',
+ '시흥',
];
diff --git a/src/locales/ko/address/street_root.ts b/src/locales/ko/address/street_root.ts
index ac2d95da299..a1c055f3578 100644
--- a/src/locales/ko/address/street_root.ts
+++ b/src/locales/ko/address/street_root.ts
@@ -6,18 +6,15 @@ export default [
'잠실',
'면목',
'주안',
- '안양',
'중',
'정왕',
'구로',
'신월',
'연산',
- '부평',
'창',
'만수',
'중계',
'검단',
- '시흥',
'상도',
'방배',
'장유',
@@ -27,4 +24,6 @@ export default [
'행신',
'대명',
'동탄',
+ '판교',
+ '연무',
];
diff --git a/src/locales/ko/name/first_name.ts b/src/locales/ko/name/first_name.ts
index e48d0e31e63..c968e4915e1 100644
--- a/src/locales/ko/name/first_name.ts
+++ b/src/locales/ko/name/first_name.ts
@@ -3013,4 +3013,5 @@ export default [
'형건',
'경륜',
'민광',
+ '슬희',
];
diff --git a/src/locales/lv/address/street_address.ts b/src/locales/lv/address/street_address.ts
index 5987b430a30..aaf5810e3a4 100644
--- a/src/locales/lv/address/street_address.ts
+++ b/src/locales/lv/address/street_address.ts
@@ -1,4 +1,4 @@
-export default [
- '#{street_name} #{building_number}',
- '#{street_name} #{building_number} #{secondary_address}',
-];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/mk/address/street_address.ts b/src/locales/mk/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/mk/address/street_address.ts
+++ b/src/locales/mk/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/nb_NO/address/street_address.ts b/src/locales/nb_NO/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/nb_NO/address/street_address.ts
+++ b/src/locales/nb_NO/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/nl/address/street_address.ts b/src/locales/nl/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/nl/address/street_address.ts
+++ b/src/locales/nl/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/nl_BE/address/street_address.ts b/src/locales/nl_BE/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/nl_BE/address/street_address.ts
+++ b/src/locales/nl_BE/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/pl/address/street_address.ts b/src/locales/pl/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/pl/address/street_address.ts
+++ b/src/locales/pl/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/pl/address/street_prefix.ts b/src/locales/pl/address/street_prefix.ts
index 45b9ba5740f..04bf4b2b72a 100644
--- a/src/locales/pl/address/street_prefix.ts
+++ b/src/locales/pl/address/street_prefix.ts
@@ -1 +1 @@
-export default ['ul.', 'al.'];
+export default ['ul.', 'al.', 'os.'];
diff --git a/src/locales/pl/internet/domain_suffix.ts b/src/locales/pl/internet/domain_suffix.ts
index 0ecff71e0be..e40e15d94aa 100644
--- a/src/locales/pl/internet/domain_suffix.ts
+++ b/src/locales/pl/internet/domain_suffix.ts
@@ -1 +1,21 @@
-export default ['com', 'pl', 'com.pl', 'net', 'org'];
+export default [
+ 'agro.pl',
+ 'auto.pl',
+ 'biz.pl',
+ 'com.pl',
+ 'edu.pl',
+ 'gmina.pl',
+ 'gov.pl',
+ 'info.pl',
+ 'miasta.pl',
+ 'net.pl',
+ 'nieruchomosci.pl',
+ 'org.pl',
+ 'pl',
+ 'powiat.pl',
+ 'priv.pl',
+ 'sklep.pl',
+ 'szkola.pl',
+ 'targi.pl',
+ 'turystyka.pl',
+];
diff --git a/src/locales/pt_PT/address/street_address.ts b/src/locales/pt_PT/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/pt_PT/address/street_address.ts
+++ b/src/locales/pt_PT/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ro/address/street_address.ts b/src/locales/ro/address/street_address.ts
index 4a09fa36918..b8624265269 100644
--- a/src/locales/ro/address/street_address.ts
+++ b/src/locales/ro/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}, #{building_number}, #{secondary_address}'];
+export default {
+ normal: '{{address.streetName}}, {{address.buildingNumber}}',
+ full: '{{address.streetName}}, {{address.buildingNumber}}, {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ru/address/street_address.ts b/src/locales/ru/address/street_address.ts
index a6c7cff8a2d..73037a5c55f 100644
--- a/src/locales/ru/address/street_address.ts
+++ b/src/locales/ru/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}, #{building_number}'];
+export default {
+ normal: '{{address.streetName}}, {{address.buildingNumber}}',
+ full: '{{address.streetName}}, {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/sk/address/street_address.ts b/src/locales/sk/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/sk/address/street_address.ts
+++ b/src/locales/sk/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/sv/address/street_address.ts b/src/locales/sv/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/sv/address/street_address.ts
+++ b/src/locales/sv/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/tr/address/street_address.ts b/src/locales/tr/address/street_address.ts
index 51642bdd055..aaf5810e3a4 100644
--- a/src/locales/tr/address/street_address.ts
+++ b/src/locales/tr/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name} #{building_number}'];
+export default {
+ normal: '{{address.streetName}} {{address.buildingNumber}}',
+ full: '{{address.streetName}} {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/uk/address/street_address.ts b/src/locales/uk/address/street_address.ts
index a6c7cff8a2d..73037a5c55f 100644
--- a/src/locales/uk/address/street_address.ts
+++ b/src/locales/uk/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}, #{building_number}'];
+export default {
+ normal: '{{address.streetName}}, {{address.buildingNumber}}',
+ full: '{{address.streetName}}, {{address.buildingNumber}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/ur/address/index.ts b/src/locales/ur/address/index.ts
index 312e90271ab..a04af9074df 100644
--- a/src/locales/ur/address/index.ts
+++ b/src/locales/ur/address/index.ts
@@ -12,7 +12,6 @@ import country from './country';
import default_country from './default_country';
import direction from './direction';
import postcode from './postcode';
-import postcode_by_state from './postcode_by_state';
import secondary_address from './secondary_address';
import state from './state';
import state_abbr from './state_abbr';
@@ -30,7 +29,6 @@ const address = {
default_country,
direction,
postcode,
- postcode_by_state,
secondary_address,
state,
state_abbr,
diff --git a/src/locales/ur/address/postcode_by_state.ts b/src/locales/ur/address/postcode_by_state.ts
deleted file mode 100644
index db2bcfedae5..00000000000
--- a/src/locales/ur/address/postcode_by_state.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['#####'];
diff --git a/src/locales/ur/address/street_address.ts b/src/locales/ur/address/street_address.ts
index 0fcaf4695d6..d6c5878a730 100644
--- a/src/locales/ur/address/street_address.ts
+++ b/src/locales/ur/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{building_number} #{street_name}'];
+export default {
+ normal: '{{address.buildingNumber}} {{address.streetName}}',
+ full: '{{address.buildingNumber}} {{address.streetName}} {{address.secondaryAddress}}',
+};
diff --git a/src/locales/zh_CN/address/street_address.ts b/src/locales/zh_CN/address/street_address.ts
index ad30a40d255..4b7603430c1 100644
--- a/src/locales/zh_CN/address/street_address.ts
+++ b/src/locales/zh_CN/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}#{building_number}号'];
+export default {
+ normal: '{{address.streetName}}{{address.buildingNumber}}号',
+ full: '{{address.streetName}}{{address.buildingNumber}}号 {{address.secondaryAddress}}',
+};
diff --git a/src/locales/zh_TW/address/street_address.ts b/src/locales/zh_TW/address/street_address.ts
index cb37c30c607..21e9547332c 100644
--- a/src/locales/zh_TW/address/street_address.ts
+++ b/src/locales/zh_TW/address/street_address.ts
@@ -1 +1,4 @@
-export default ['#{street_name}#{building_number}號'];
+export default {
+ normal: '{{address.streetName}}{{address.buildingNumber}}號',
+ full: '{{address.streetName}}{{address.buildingNumber}}號 {{address.secondaryAddress}}',
+};
diff --git a/src/lorem.ts b/src/lorem.ts
index 296c88b50c0..a605aa2f743 100644
--- a/src/lorem.ts
+++ b/src/lorem.ts
@@ -31,7 +31,7 @@ export class Lorem {
word(length?: number): string {
const hasRightLength = (word: string) => word.length === length;
let properLengthWords: readonly string[];
- if (typeof length === 'undefined') {
+ if (length == null) {
properLengthWords = this.faker.definitions.lorem.words;
} else {
properLengthWords =
@@ -49,10 +49,7 @@ export class Lorem {
* faker.lorem.words() // 'qui praesentium pariatur'
* faker.lorem.words(10) // 'debitis consectetur voluptatem non doloremque ipsum autem totam eum ratione'
*/
- words(num?: number): string {
- if (typeof num === 'undefined') {
- num = 3;
- }
+ words(num: number = 3): string {
const words: string[] = [];
for (let i = 0; i < num; i++) {
words.push(this.faker.lorem.word());
@@ -64,21 +61,15 @@ export class Lorem {
* Generates a space separated list of words beginning a capital letter and ending with a dot.
*
* @param wordCount The number of words, that should be in the sentence. Defaults to a random number between `3` and `10`.
- * @param range Currently this parameter does nothing.
*
* @example
* faker.lorem.sentence() // 'Voluptatum cupiditate suscipit autem eveniet aut dolorem aut officiis distinctio.'
* faker.lorem.sentence(5) // 'Laborum voluptatem officiis est et.'
*/
- // TODO @Shinigami92 2022-01-11: `range` is not in use
- sentence(wordCount?: number, range?: number): string {
- if (typeof wordCount === 'undefined') {
+ sentence(wordCount?: number): string {
+ if (wordCount == null) {
wordCount = this.faker.datatype.number({ min: 3, max: 10 });
}
- // if (typeof range == 'undefined') { range = 7; }
-
- // strange issue with the node_min_test failing for capitalize, please fix and add faker.lorem.back
- //return faker.lorem.words(wordCount + Helpers.randomNumber(range)).join(' ').capitalize();
const sentence = this.faker.lorem.words(wordCount);
return sentence.charAt(0).toUpperCase() + sentence.slice(1) + '.';
@@ -110,13 +101,10 @@ export class Lorem {
* // 'Et rerum a unde tempora magnam sit nisi.
* // Et perspiciatis ipsam omnis.'
*/
- sentences(sentenceCount?: number, separator?: string): string {
- if (typeof sentenceCount === 'undefined') {
+ sentences(sentenceCount?: number, separator: string = ' '): string {
+ if (sentenceCount == null) {
sentenceCount = this.faker.datatype.number({ min: 2, max: 6 });
}
- if (typeof separator === 'undefined') {
- separator = ' ';
- }
const sentences: string[] = [];
for (sentenceCount; sentenceCount > 0; sentenceCount--) {
sentences.push(this.faker.lorem.sentence());
@@ -143,7 +131,7 @@ export class Lorem {
* Generates the given number of paragraphs.
*
* @param paragraphCount The number of paragraphs to generate. Defaults to `3`.
- * @param separator The separator to use. Defaults to `'\n \r'`.
+ * @param separator The separator to use. Defaults to `'\n'`.
*
* @example
* faker.lorem.paragraphs()
@@ -162,8 +150,7 @@ export class Lorem {
* // 'Eos magnam aut qui accusamus. Sapiente quas culpa totam excepturi. Blanditiis totam distinctio occaecati dignissimos cumque atque qui officiis.
* // Nihil quis vel consequatur. Blanditiis commodi deserunt sunt animi dolorum. A optio porro hic dolorum fugit aut et sint voluptas. Minima ad sed ipsa est non dolores.'
*/
- // TODO ST-DDT 2022-02-09: The separator looks odd.
- paragraphs(paragraphCount: number = 3, separator: string = '\n \r'): string {
+ paragraphs(paragraphCount: number = 3, separator: string = '\n'): string {
const paragraphs: string[] = [];
for (paragraphCount; paragraphCount > 0; paragraphCount--) {
paragraphs.push(this.faker.lorem.paragraph());
@@ -174,8 +161,6 @@ export class Lorem {
/**
* Generates a random text based on a random lorem method.
*
- * @param times This parameter does nothing.
- *
* @example
* faker.lorem.text() // 'Doloribus autem non quis vero quia.'
* faker.lorem.text()
@@ -185,19 +170,20 @@ export class Lorem {
* // Iure nam officia optio cumque.
* // Dolor tempora iusto.'
*/
- // TODO @Shinigami92 2022-01-11: `times` is not in use
- text(times?: number): string {
- const loremMethods = [
- 'lorem.word',
- 'lorem.words',
- 'lorem.sentence',
- 'lorem.sentences',
- 'lorem.paragraph',
- 'lorem.paragraphs',
- 'lorem.lines',
+ text(): string {
+ const methods: Array = [
+ 'word',
+ 'words',
+ 'sentence',
+ 'sentences',
+ 'paragraph',
+ 'paragraphs',
+ 'lines',
];
- const randomLoremMethod = this.faker.random.arrayElement(loremMethods);
- return this.faker.fake(`{{${randomLoremMethod}}}`);
+
+ const method = this.faker.random.arrayElement(methods);
+
+ return `${this[method]()}`;
}
/**
@@ -217,7 +203,7 @@ export class Lorem {
* // Voluptate aut aut.'
*/
lines(lineCount?: number): string {
- if (typeof lineCount === 'undefined') {
+ if (lineCount == null) {
lineCount = this.faker.datatype.number({ min: 1, max: 5 });
}
return this.faker.lorem.sentences(lineCount, '\n');
diff --git a/src/mersenne.ts b/src/mersenne.ts
index 6539d738bc7..21f52f6c0ef 100644
--- a/src/mersenne.ts
+++ b/src/mersenne.ts
@@ -1,4 +1,5 @@
-import Gen from './vendor/mersenne';
+import { FakerError } from './errors/faker-error';
+import Gen from './utils/mersenne';
/**
* Module to generate seed based random numbers.
@@ -22,18 +23,17 @@ export class Mersenne {
* Generates a random number between `[min, max)`.
*
* @param max The maximum number. Defaults to `0`.
- * @param min The minimum number. Defaults to `32768`. Required if `max` is set.
+ * @param min The minimum number. Defaults to `32768`.
*
* @example
* faker.mersenne.rand() // 15515
* faker.mersenne.rand(500, 1000) // 578
*/
- rand(max?: number, min?: number): number {
- // TODO @Shinigami92 2022-01-11: This is buggy, cause if min is not passed but only max,
- // then min will be undefined and this result in NaN for the whole function
- if (max === undefined) {
- min = 0;
- max = 32768;
+ rand(max = 32768, min = 0): number {
+ if (min > max) {
+ const temp = min;
+ min = max;
+ max = temp;
}
return Math.floor(this.gen.genrandReal2() * (max - min) + min);
@@ -47,7 +47,9 @@ export class Mersenne {
*/
seed(S: number): void {
if (typeof S !== 'number') {
- throw new Error('seed(S) must take numeric argument; is ' + typeof S);
+ throw new FakerError(
+ 'seed(S) must take numeric argument; is ' + typeof S
+ );
}
this.gen.initGenrand(S);
@@ -61,7 +63,7 @@ export class Mersenne {
*/
seed_array(A: number[]): void {
if (typeof A !== 'object') {
- throw new Error(
+ throw new FakerError(
'seed_array(A) must take array of numbers; is ' + typeof A
);
}
diff --git a/src/name.ts b/src/name.ts
index 6b7275692eb..9ac270b323f 100644
--- a/src/name.ts
+++ b/src/name.ts
@@ -1,4 +1,90 @@
import type { Faker } from '.';
+import { deprecated } from './internal/deprecated';
+
+export enum Gender {
+ female = 'female',
+ male = 'male',
+}
+
+// TODO @Shinigami92 21-03-2022: Remove 0 and 1 in v7
+export type GenderType = 'female' | 'male' | 0 | 1;
+
+/**
+ * Normalize gender.
+ *
+ * @param gender Gender.
+ * @param functionName Temporary parameter for deprecation message.
+ * @returns Normalized gender.
+ */
+function normalizeGender(
+ gender?: GenderType,
+ functionName?: string
+): Exclude | undefined {
+ if (gender == null || typeof gender === 'string') {
+ // TODO @Shinigami92 21-03-2022: Cast can be removed when we set `strict: true`
+ return gender as Exclude;
+ }
+
+ const normalizedGender = gender === 0 ? 'male' : 'female';
+
+ deprecated({
+ deprecated: `name.${functionName}(number)`,
+ proposed: "'female' or 'male'",
+ since: 'v6.1.0',
+ until: 'v7.0.0',
+ });
+
+ return normalizedGender;
+}
+
+/**
+ * Select a definition based on given gender.
+ *
+ * @param faker Faker instance.
+ * @param gender Gender.
+ * @param param2 Definitions.
+ * @param param2.generic Non-gender definitions.
+ * @param param2.female Female definitions.
+ * @param param2.male Male definitions.
+ * @param functionName Temporary parameter for deprecation message.
+ * @returns Definition based on given gender.
+ */
+function selectDefinition(
+ faker: Faker,
+ gender: GenderType | undefined,
+ // TODO christopher 21-03-2022: Remove fallback empty object when `strict: true`
+ {
+ generic,
+ female,
+ male,
+ }: { generic?: string[]; female?: string[]; male?: string[] } = {},
+ functionName?: string
+) {
+ const normalizedGender = normalizeGender(gender, functionName);
+
+ let values: string[] | undefined;
+ switch (normalizedGender) {
+ case 'female':
+ values = female;
+ break;
+ case 'male':
+ values = male;
+ break;
+ default:
+ values = generic;
+ break;
+ }
+
+ if (values == null) {
+ if (female != null && male != null) {
+ values = faker.random.arrayElement([female, male]);
+ } else {
+ values = generic;
+ }
+ }
+
+ return faker.random.arrayElement(values);
+}
/**
* Module to generate people's names and titles.
@@ -18,54 +104,26 @@ export class Name {
* Returns a random first name.
*
* @param gender The optional gender to use.
- * Can be either `'male'` (or `0`) or `'female'` (or `1`).
+ * Can be either `'female'` or `'male'`.
*
* @example
* faker.name.firstName() // 'Antwan'
* faker.name.firstName("female") // 'Victoria'
- * faker.name.firstName(1) // 'Ashley'
* faker.name.firstName("male") // 'Tom'
- * faker.name.firstName(0) // 'Ismael'
*/
- firstName(gender?: string | number): string {
- if (
- typeof this.faker.definitions.name.male_first_name !== 'undefined' &&
- typeof this.faker.definitions.name.female_first_name !== 'undefined'
- ) {
- // some locale datasets ( like ru ) have first_name split by gender. since the name.first_name field does not exist in these datasets,
- // we must randomly pick a name from either gender array so faker.name.firstName will return the correct locale data ( and not fallback )
-
- if (typeof gender === 'string') {
- if (gender.toLowerCase() === 'male') {
- gender = 0;
- } else if (gender.toLowerCase() === 'female') {
- gender = 1;
- }
- }
-
- if (typeof gender !== 'number') {
- if (typeof this.faker.definitions.name.first_name === 'undefined') {
- gender = this.faker.datatype.number(1);
- } else {
- // Fall back to non-gendered names if they exist and gender wasn't specified
- return this.faker.random.arrayElement(
- this.faker.definitions.name.first_name
- );
- }
- }
- if (gender === 0) {
- return this.faker.random.arrayElement(
- this.faker.definitions.name.male_first_name
- );
- } else {
- return this.faker.random.arrayElement(
- this.faker.definitions.name.female_first_name
- );
- }
- }
+ firstName(gender?: GenderType): string {
+ const { first_name, female_first_name, male_first_name } =
+ this.faker.definitions.name;
- return this.faker.random.arrayElement(
- this.faker.definitions.name.first_name
+ return selectDefinition(
+ this.faker,
+ gender,
+ {
+ generic: first_name,
+ female: female_first_name,
+ male: male_first_name,
+ },
+ 'firstName'
);
}
@@ -73,38 +131,26 @@ export class Name {
* Returns a random last name.
*
* @param gender The optional gender to use.
- * Can be either `'male'` (or `0`) or `'female'` (or `1`).
+ * Can be either `'female'` or `'male'`.
*
* @example
* faker.name.lastName() // 'Hauck'
* faker.name.lastName("female") // 'Grady'
- * faker.name.lastName(1) // 'Kshlerin'
* faker.name.lastName("male") // 'Barton'
- * faker.name.lastName(0) // 'Lockman'
*/
- lastName(gender?: string | number): string {
- if (
- typeof this.faker.definitions.name.male_last_name !== 'undefined' &&
- typeof this.faker.definitions.name.female_last_name !== 'undefined'
- ) {
- // some locale datasets ( like ru ) have last_name split by gender. i have no idea how last names can have genders, but also i do not speak russian
- // see above comment of firstName method
- if (typeof gender !== 'number') {
- gender = this.faker.datatype.number(1);
- }
- if (gender === 0) {
- return this.faker.random.arrayElement(
- this.faker.locales[this.faker.locale].name.male_last_name
- );
- } else {
- return this.faker.random.arrayElement(
- this.faker.locales[this.faker.locale].name.female_last_name
- );
- }
- }
+ lastName(gender?: GenderType): string {
+ const { last_name, female_last_name, male_last_name } =
+ this.faker.definitions.name;
- return this.faker.random.arrayElement(
- this.faker.definitions.name.last_name
+ return selectDefinition(
+ this.faker,
+ gender,
+ {
+ generic: last_name,
+ female: female_last_name,
+ male: male_last_name,
+ },
+ 'lastName'
);
}
@@ -112,36 +158,26 @@ export class Name {
* Returns a random middle name.
*
* @param gender The optional gender to use.
- * Can be either `'male'` (or `0`) or `'female'` (or `1`).
+ * Can be either `'female'` or `'male'`.
*
* @example
* faker.name.middleName() // 'Доброславівна'
* faker.name.middleName("female") // 'Анастасівна'
- * faker.name.middleName(1) // 'Анатоліївна'
* faker.name.middleName("male") // 'Вікторович'
- * faker.name.middleName(0) // 'Стефанович'
*/
- middleName(gender?: string | number): string {
- if (
- typeof this.faker.definitions.name.male_middle_name !== 'undefined' &&
- typeof this.faker.definitions.name.female_middle_name !== 'undefined'
- ) {
- if (typeof gender !== 'number') {
- gender = this.faker.datatype.number(1);
- }
- if (gender === 0) {
- return this.faker.random.arrayElement(
- this.faker.definitions.name.male_middle_name
- );
- } else {
- return this.faker.random.arrayElement(
- this.faker.definitions.name.female_middle_name
- );
- }
- }
+ middleName(gender?: GenderType): string {
+ const { middle_name, female_middle_name, male_middle_name } =
+ this.faker.definitions.name;
- return this.faker.random.arrayElement(
- this.faker.definitions.name.middle_name
+ return selectDefinition(
+ this.faker,
+ gender,
+ {
+ generic: middle_name,
+ female: female_middle_name,
+ male: male_middle_name,
+ },
+ 'middleName'
);
}
@@ -151,35 +187,29 @@ export class Name {
* @param firstName The optional first name to use. If not specified a random one will be chosen.
* @param lastName The optional last name to use. If not specified a random one will be chosen.
* @param gender The optional gender to use.
- * Can be either `'male'` (or `0`) or `'female'` (or `1`).
+ * Can be either `'female'` or `'male'`.
*
* @example
* faker.name.findName() // 'Allen Brown'
* faker.name.findName('Joann') // 'Joann Osinski'
- * faker.name.findName('Marcella', '', 1) // 'Mrs. Marcella Huels'
+ * faker.name.findName('Marcella', '', 'female') // 'Mrs. Marcella Huels'
* faker.name.findName(undefined, 'Beer') // 'Mr. Alfonso Beer'
- * faker.name.findName(undefined, undefined, 0) // 'Fernando Schaefer'
+ * faker.name.findName(undefined, undefined, 'male') // 'Fernando Schaefer'
*/
- findName(
- firstName?: string,
- lastName?: string,
- gender?: string | number
- ): string {
- const r = this.faker.datatype.number(8);
+ findName(firstName?: string, lastName?: string, gender?: GenderType): string {
+ const variant = this.faker.datatype.number(8);
let prefix = '';
let suffix = '';
- // in particular locales first and last names split by gender,
- // thus we keep consistency by passing 0 as male and 1 as female
-
- if (typeof gender !== 'number') {
- gender = this.faker.datatype.number(1);
- }
+ const normalizedGender: Exclude =
+ normalizeGender(gender, 'findName') ??
+ this.faker.random.arrayElement(['female', 'male']);
- firstName = firstName || this.faker.name.firstName(gender);
- lastName = lastName || this.faker.name.lastName(gender);
+ firstName = firstName || this.faker.name.firstName(normalizedGender);
+ lastName = lastName || this.faker.name.lastName(normalizedGender);
- switch (r) {
+ switch (variant) {
+ // TODO christopher 21-03-2022: Add possibility to have a prefix together with a suffix
case 0:
prefix = this.faker.name.prefix(gender);
if (prefix) {
@@ -197,22 +227,6 @@ export class Name {
return firstName + ' ' + lastName;
}
- /**
- * Generates a random job title.
- *
- * @example
- * faker.name.jobTitle() // 'Global Accounts Engineer'
- */
- jobTitle(): string {
- return (
- this.faker.name.jobDescriptor() +
- ' ' +
- this.faker.name.jobArea() +
- ' ' +
- this.faker.name.jobType()
- );
- }
-
/**
* Return a random gender.
*
@@ -227,44 +241,35 @@ export class Name {
return this.faker.random.arrayElement(
this.faker.definitions.name.binary_gender
);
- } else {
- return this.faker.random.arrayElement(this.faker.definitions.name.gender);
}
+
+ return this.faker.random.arrayElement(this.faker.definitions.name.gender);
}
/**
* Returns a random name prefix.
*
* @param gender The optional gender to use.
- * Can be either `'male'` (or `0`) or `'female'` (or `1`).
+ * Can be either `'female'` or `'male'`.
*
* @example
* faker.name.prefix() // 'Miss'
* faker.name.prefix('female') // 'Ms.'
- * faker.name.prefix(1) // 'Dr.'
* faker.name.prefix('male') // 'Mr.'
- * faker.name.prefix(0) // 'Mr.'
*/
- prefix(gender?: string | number): string {
- if (
- typeof this.faker.definitions.name.male_prefix !== 'undefined' &&
- typeof this.faker.definitions.name.female_prefix !== 'undefined'
- ) {
- if (typeof gender !== 'number') {
- gender = this.faker.datatype.number(1);
- }
- if (gender === 0) {
- return this.faker.random.arrayElement(
- this.faker.locales[this.faker.locale].name.male_prefix
- );
- } else {
- return this.faker.random.arrayElement(
- this.faker.locales[this.faker.locale].name.female_prefix
- );
- }
- }
+ prefix(gender?: GenderType): string {
+ const { prefix, female_prefix, male_prefix } = this.faker.definitions.name;
- return this.faker.random.arrayElement(this.faker.definitions.name.prefix);
+ return selectDefinition(
+ this.faker,
+ gender,
+ {
+ generic: prefix,
+ female: female_prefix,
+ male: male_prefix,
+ },
+ 'prefix'
+ );
}
/**
@@ -274,27 +279,37 @@ export class Name {
* faker.name.suffix() // 'DDS'
*/
suffix(): string {
+ // TODO christopher 21-03-2022: Add female_suffix and male_suffix
return this.faker.random.arrayElement(this.faker.definitions.name.suffix);
}
/**
- * Generates a random title.
+ * Generates a random job title.
*
* @example
* faker.name.title() // 'International Integration Manager'
+ *
+ * @deprecated
*/
title(): string {
- const descriptor = this.faker.random.arrayElement(
- this.faker.definitions.name.title.descriptor
- );
- const level = this.faker.random.arrayElement(
- this.faker.definitions.name.title.level
- );
- const job = this.faker.random.arrayElement(
- this.faker.definitions.name.title.job
- );
+ deprecated({
+ deprecated: 'faker.name.title()',
+ proposed: 'faker.name.jobTitle()',
+ since: 'v6.1.2',
+ until: 'v7.0.0',
+ });
- return descriptor + ' ' + level + ' ' + job;
+ return this.jobTitle();
+ }
+
+ /**
+ * Generates a random job title.
+ *
+ * @example
+ * faker.name.jobTitle() // 'Global Accounts Engineer'
+ */
+ jobTitle(): string {
+ return this.jobDescriptor() + ' ' + this.jobArea() + ' ' + this.jobType();
}
/**
diff --git a/src/random.ts b/src/random.ts
index c2d8ecb2bb4..448cf4f8696 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -1,4 +1,6 @@
import type { Faker } from '.';
+import { FakerError } from './errors/faker-error';
+import { deprecated } from './internal/deprecated';
/**
* Method to reduce array of characters.
@@ -18,14 +20,7 @@ function arrayRemove(arr: T[], values: T[]): T[] {
* Generates random values of different kinds. Some methods are deprecated and have been moved to dedicated modules.
*/
export class Random {
- constructor(private readonly faker: Faker, seed?: number | number[]) {
- // Use a user provided seed if it is an array or number
- if (Array.isArray(seed) && seed.length) {
- this.faker.mersenne.seed_array(seed);
- } else if (!Array.isArray(seed) && !isNaN(seed)) {
- this.faker.mersenne.seed(seed);
- }
-
+ constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Random.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
@@ -59,9 +54,12 @@ export class Random {
number(
options?: number | { min?: number; max?: number; precision?: number }
): number {
- console.warn(
- 'Deprecation Warning: faker.random.number is now located in faker.datatype.number'
- );
+ deprecated({
+ deprecated: 'faker.random.number()',
+ proposed: 'faker.datatype.number()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.datatype.number(options);
}
@@ -88,9 +86,12 @@ export class Random {
float(
options?: number | { min?: number; max?: number; precision?: number }
): number {
- console.warn(
- 'Deprecation Warning: faker.random.float is now located in faker.datatype.float'
- );
+ deprecated({
+ deprecated: 'faker.random.float()',
+ proposed: 'faker.datatype.float()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.datatype.float(options);
}
@@ -107,8 +108,12 @@ export class Random {
arrayElement(
array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray
): T {
- const r = this.faker.datatype.number({ max: array.length - 1 });
- return array[r];
+ const index =
+ array.length > 1
+ ? this.faker.datatype.number({ max: array.length - 1 })
+ : 0;
+
+ return array[index];
}
/**
@@ -220,9 +225,12 @@ export class Random {
* @deprecated
*/
uuid(): string {
- console.warn(
- 'Deprecation Warning: faker.random.uuid is now located in faker.datatype.uuid'
- );
+ deprecated({
+ deprecated: 'faker.random.uuid()',
+ proposed: 'faker.datatype.uuid()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.datatype.uuid();
}
@@ -237,9 +245,12 @@ export class Random {
* @deprecated
*/
boolean(): boolean {
- console.warn(
- 'Deprecation Warning: faker.random.boolean is now located in faker.datatype.boolean'
- );
+ deprecated({
+ deprecated: 'faker.random.boolean()',
+ proposed: 'faker.datatype.boolean()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.datatype.boolean();
}
@@ -249,45 +260,74 @@ export class Random {
* @example
* faker.random.word() // 'Seamless'
*/
- // TODO: have ability to return specific type of word? As in: noun, adjective, verb, etc
word(): string {
const wordMethods = [
- 'commerce.department',
- 'commerce.productName',
- 'commerce.productAdjective',
- 'commerce.productMaterial',
- 'commerce.product',
- 'commerce.color',
-
- 'company.catchPhraseAdjective',
- 'company.catchPhraseDescriptor',
- 'company.catchPhraseNoun',
- 'company.bsAdjective',
- 'company.bsBuzz',
- 'company.bsNoun',
- 'address.streetSuffix',
- 'address.county',
- 'address.country',
- 'address.state',
-
- 'finance.accountName',
- 'finance.transactionType',
- 'finance.currencyName',
-
- 'hacker.noun',
- 'hacker.verb',
- 'hacker.adjective',
- 'hacker.ingverb',
- 'hacker.abbreviation',
-
- 'name.jobDescriptor',
- 'name.jobArea',
- 'name.jobType',
+ this.faker.commerce.department,
+ this.faker.commerce.productName,
+ this.faker.commerce.productAdjective,
+ this.faker.commerce.productMaterial,
+ this.faker.commerce.product,
+ this.faker.commerce.color,
+
+ this.faker.company.catchPhraseAdjective,
+ this.faker.company.catchPhraseDescriptor,
+ this.faker.company.catchPhraseNoun,
+ this.faker.company.bsAdjective,
+ this.faker.company.bsBuzz,
+ this.faker.company.bsNoun,
+ this.faker.address.streetSuffix,
+ this.faker.address.county,
+ this.faker.address.country,
+ this.faker.address.state,
+
+ this.faker.finance.accountName,
+ this.faker.finance.transactionType,
+ this.faker.finance.currencyName,
+
+ this.faker.hacker.noun,
+ this.faker.hacker.verb,
+ this.faker.hacker.adjective,
+ this.faker.hacker.ingverb,
+ this.faker.hacker.abbreviation,
+
+ this.faker.name.jobDescriptor,
+ this.faker.name.jobArea,
+ this.faker.name.jobType,
+ ];
+
+ const bannedChars = [
+ '!',
+ '#',
+ '%',
+ '&',
+ '*',
+ ')',
+ '(',
+ '+',
+ '=',
+ '.',
+ '<',
+ '>',
+ '{',
+ '}',
+ '[',
+ ']',
+ ':',
+ ';',
+ "'",
+ '"',
+ '_',
+ '-',
];
+ let result: string;
+
+ do {
+ // randomly pick from the many faker methods that can generate words
+ const randomWordMethod = this.faker.random.arrayElement(wordMethods);
+
+ result = randomWordMethod();
+ } while (!result || bannedChars.some((char) => result.includes(char)));
- // randomly pick from the many faker methods that can generate words
- const randomWordMethod = this.faker.random.arrayElement(wordMethods);
- const result = this.faker.fake('{{' + randomWordMethod + '}}');
return this.faker.random.arrayElement(result.split(' '));
}
@@ -303,7 +343,7 @@ export class Random {
words(count?: number): string {
const words: string[] = [];
- if (typeof count === 'undefined') {
+ if (count == null) {
count = this.faker.datatype.number({ min: 1, max: 3 });
}
@@ -325,9 +365,12 @@ export class Random {
* @deprecated
*/
image(): string {
- console.warn(
- 'Deprecation Warning: faker.random.image is now located in faker.image.image'
- );
+ deprecated({
+ deprecated: 'faker.random.image()',
+ proposed: 'faker.image.image()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
return this.faker.image.image();
}
@@ -361,7 +404,7 @@ export class Random {
| number
| { count?: number; upcase?: boolean; bannedChars?: string[] }
): string {
- if (typeof options === 'undefined') {
+ if (options == null) {
options = {
count: 1,
};
@@ -369,14 +412,14 @@ export class Random {
options = {
count: options,
};
- } else if (typeof options.count === 'undefined') {
+ } else if (options.count == null) {
options.count = 1;
}
- if (typeof options.upcase === 'undefined') {
+ if (options.upcase == null) {
options.upcase = false;
}
- if (typeof options.bannedChars === 'undefined') {
+ if (options.bannedChars == null) {
options.bannedChars = [];
}
@@ -436,7 +479,7 @@ export class Random {
count: number = 1,
options: { bannedChars?: string[] } = {}
): string {
- if (typeof options.bannedChars === 'undefined') {
+ if (options.bannedChars == null) {
options.bannedChars = [];
}
@@ -479,11 +522,17 @@ export class Random {
'y',
'z',
];
- if (options) {
- if (options.bannedChars) {
- charsArray = arrayRemove(charsArray, options.bannedChars);
- }
+
+ if (options.bannedChars) {
+ charsArray = arrayRemove(charsArray, options.bannedChars);
}
+
+ if (charsArray.length === 0) {
+ throw new FakerError(
+ 'Unable to generate string, because all possible characters are banned.'
+ );
+ }
+
for (let i = 0; i < count; i++) {
wholeString += this.faker.random.arrayElement(charsArray);
}
@@ -496,18 +545,22 @@ export class Random {
*
* @param count Length of the generated number. Defaults to `1`.
*
- * @see faker.datatype.hexaDecimal()
+ * @see faker.datatype.hexadecimal()
*
* @example
- * faker.datatype.hexaDecimal() // '0xb'
- * faker.datatype.hexaDecimal(10) // '0xaE13F044fb'
+ * faker.random.hexaDecimal() // '0xb'
+ * faker.random.hexaDecimal(10) // '0xaE13F044fb'
*
* @deprecated
*/
hexaDecimal(count?: number): string {
- console.warn(
- 'Deprecation Warning: faker.random.hexaDecimal is now located in faker.datatype.hexaDecimal'
- );
- return this.faker.datatype.hexaDecimal(count);
+ deprecated({
+ deprecated: 'faker.random.hexaDecimal()',
+ proposed: 'faker.datatype.hexadecimal()',
+ // since: 'v5.0.0', (?)
+ until: 'v7.0.0',
+ });
+
+ return this.faker.datatype.hexadecimal(count);
}
}
diff --git a/src/system.ts b/src/system.ts
index 33413a23bc6..c5b052c0a80 100644
--- a/src/system.ts
+++ b/src/system.ts
@@ -14,6 +14,12 @@ const commonMimeTypes = [
'text/html',
];
+/**
+ * Converts the given set to an array.
+ *
+ * @param set The set to convert.
+ */
+// TODO ST-DDT 2022-03-11: Replace with Array.from(Set)
function setToArray(set: Set): T[] {
// shortcut if Array.from is available
if (Array.from) {
@@ -169,12 +175,11 @@ export class System {
* Returns a file path.
*
* @example
- * faker.system.filePath() // '/usr/local/src/money.rmp.dotx'
+ * faker.system.filePath() // '/usr/local/src/money.dotx'
*/
+ // TODO @prisis 2022-01-25: add a parameter to have the possibility to have one or two ext on file.
filePath(): string {
- return this.faker.fake(
- '{{system.directoryPath}}/{{system.fileName}}.{{system.fileExt}}'
- );
+ return `${this.directoryPath()}/${this.fileName()}`;
}
/**
diff --git a/src/time.ts b/src/time.ts
index 2d376839a06..8eeaef421a4 100644
--- a/src/time.ts
+++ b/src/time.ts
@@ -1,7 +1,10 @@
import type { LiteralUnion } from './faker';
+import { deprecated } from './internal/deprecated';
/**
* Module to generate time of dates in various formats.
+ *
+ * @deprecated You should stop using this module, as it will be removed in the future.
*/
export class Time {
/**
@@ -20,11 +23,19 @@ export class Time {
* faker.time.recent('date') // 2022-03-01T20:35:47.402Z
* faker.time.recent('wide') // '00:34:11 GMT+0100 (Central European Standard Time)'
* faker.time.recent('unix') // 1643067231856
+ *
+ * @deprecated You should stop using this function, as it will be removed in the future. Use the native `new Date()` with one of the wanted functions directly.
*/
recent(
format: LiteralUnion<'abbr' | 'date' | 'wide' | 'unix'> = 'unix'
): string | number | Date {
- // TODO ST-DDT 2022-03-01: Deprecate for removal - #557
+ deprecated({
+ deprecated: 'faker.time.recent()',
+ proposed: 'native `new Date()` and call the function you want on it',
+ since: 'v6.1.0',
+ until: 'v7.0.0',
+ });
+
let date: string | number | Date = new Date();
switch (format) {
diff --git a/src/unique.ts b/src/unique.ts
index 6ef5eee5502..b19f6132dd5 100644
--- a/src/unique.ts
+++ b/src/unique.ts
@@ -1,5 +1,5 @@
-import type { RecordKey } from './vendor/unique';
-import * as uniqueExec from './vendor/unique';
+import type { RecordKey } from './utils/unique';
+import * as uniqueExec from './utils/unique';
/**
* Module to generate unique entries.
@@ -40,7 +40,7 @@ export class Unique {
* @param opts.compare The function used to determine whether a value was already returned.
*
* @example
- * faker.unique(faker.name.firstName)
+ * faker.unique(faker.name.firstName) // 'Corbin'
*/
unique RecordKey>(
method: Method,
diff --git a/src/utils/mersenne.ts b/src/utils/mersenne.ts
new file mode 100644
index 00000000000..5859f3ae671
--- /dev/null
+++ b/src/utils/mersenne.ts
@@ -0,0 +1,320 @@
+/**
+ * Copyright (c) 2022 Faker
+ *
+ * This is a version of the original source code migrated to TypeScript and
+ * modified by the Faker team.
+ *
+ * Check LICENSE for more details on copyright.
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (c) 2006 Y. Okada
+ *
+ * This program is a JavaScript version of Mersenne Twister, with concealment
+ * and encapsulation in class, an almost straight conversion from the original
+ * program, mt19937ar.c, translated by Y. Okada on July 17, 2006, and modified
+ * a little at July 20, 2006, but there are not any substantial differences.
+ *
+ * In this program, procedure descriptions and comments of original source code
+ * were not removed.
+ *
+ * Lines commented with //c// were originally descriptions of c procedure.
+ * And a few following lines are appropriate JavaScript descriptions.
+ *
+ * Lines commented with /* and *\/ are original comments.
+ * Lines commented with // are additional comments in this JavaScript version.
+ *
+ * Before using this version, create at least one instance of
+ * MersenneTwister19937 class, and initialize the each state, given below
+ * in C comments, of all the instances.
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * A C-program for MT19937, with initialization improved 2002/1/26.
+ * Coded by Takuji Nishimura and Makoto Matsumoto.
+ *
+ * Before using, initialize the state by using init_genrand(seed)
+ * or init_by_array(init_key, key_length).
+ *
+ * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The names of its contributors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Any feedback is very welcome.
+ * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+ * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+ */
+
+export default class MersenneTwister19937 {
+ private readonly N = 624;
+ private readonly M = 397;
+ private readonly MATRIX_A = 0x9908b0df; // constant vector a
+ private readonly UPPER_MASK = 0x80000000; // most significant w-r bits
+ private readonly LOWER_MASK = 0x7fffffff; // least significant r bits
+ private mt: number[] = new Array(this.N); // the array for the state vector
+ private mti = this.N + 1; // mti==N+1 means mt[N] is not initialized
+
+ /**
+ * Returns a 32-bits unsigned integer from an operand to which applied a bit
+ * operator.
+ *
+ * @param n1 number to unsign
+ */
+ private unsigned32(n1: number): number {
+ return n1 < 0 ? (n1 ^ this.UPPER_MASK) + this.UPPER_MASK : n1;
+ }
+
+ /**
+ * Emulates lowerflow of a c 32-bits unsigned integer variable, instead of
+ * the operator -. These both arguments must be non-negative integers
+ * expressible using unsigned 32 bits.
+ *
+ * @param n1 dividend
+ * @param n2 divisor
+ */
+ private subtraction32(n1: number, n2: number): number {
+ return n1 < n2
+ ? this.unsigned32((0x100000000 - (n2 - n1)) & 0xffffffff)
+ : n1 - n2;
+ }
+
+ /**
+ * Emulates overflow of a c 32-bits unsigned integer variable, instead of the operator +.
+ * these both arguments must be non-negative integers expressible using unsigned 32 bits.
+ *
+ * @param n1 number one for addition
+ * @param n2 number two for addition
+ */
+ private addition32(n1: number, n2: number): number {
+ return this.unsigned32((n1 + n2) & 0xffffffff);
+ }
+
+ /**
+ * Emulates overflow of a c 32-bits unsigned integer variable, instead of the operator *.
+ * These both arguments must be non-negative integers expressible using unsigned 32 bits.
+ *
+ * @param n1 number one for multiplication
+ * @param n2 number two for multiplication
+ */
+ private multiplication32(n1: number, n2: number): number {
+ let sum = 0;
+ for (let i = 0; i < 32; ++i) {
+ if ((n1 >>> i) & 0x1) {
+ sum = this.addition32(sum, this.unsigned32(n2 << i));
+ }
+ }
+ return sum;
+ }
+
+ /**
+ * Initializes mt[N] with a seed.
+ *
+ * @param seed the seed to use
+ */
+ initGenrand(seed: number): void {
+ this.mt[0] = this.unsigned32(seed & 0xffffffff);
+ for (this.mti = 1; this.mti < this.N; this.mti++) {
+ this.mt[this.mti] =
+ //(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
+ this.addition32(
+ this.multiplication32(
+ 1812433253,
+ this.unsigned32(
+ this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30)
+ )
+ ),
+ this.mti
+ );
+
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+ /* In the previous versions, MSBs of the seed affect */
+ /* only MSBs of the array mt[]. */
+ /* 2002/01/09 modified by Makoto Matsumoto */
+ this.mt[this.mti] = this.unsigned32(this.mt[this.mti] & 0xffffffff);
+ }
+ }
+
+ /**
+ * Initialize by an array with array-length.
+ *
+ * @param initKey is the array for initializing keys
+ * @param keyLength is its length
+ */
+ initByArray(initKey: number[], keyLength: number): void {
+ this.initGenrand(19650218);
+ let i = 1;
+ let j = 0;
+ let k = this.N > keyLength ? this.N : keyLength;
+ for (; k; k--) {
+ // mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525)) + init_key[j] + j;
+ this.mt[i] = this.addition32(
+ this.addition32(
+ this.unsigned32(
+ this.mt[i] ^
+ this.multiplication32(
+ this.unsigned32(this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)),
+ 1664525
+ )
+ ),
+ initKey[j]
+ ),
+ j
+ );
+ // mt[i] &= 0xffffffff; for WORDSIZE > 32 machines
+ this.mt[i] = this.unsigned32(this.mt[i] & 0xffffffff);
+ i++;
+ j++;
+ if (i >= this.N) {
+ this.mt[0] = this.mt[this.N - 1];
+ i = 1;
+ }
+ if (j >= keyLength) {
+ j = 0;
+ }
+ }
+ for (k = this.N - 1; k; k--) {
+ // mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941)) - i
+ this.mt[i] = this.subtraction32(
+ this.unsigned32(
+ this.mt[i] ^
+ this.multiplication32(
+ this.unsigned32(this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)),
+ 1566083941
+ )
+ ),
+ i
+ );
+ // mt[i] &= 0xffffffff; for WORDSIZE > 32 machines
+ this.mt[i] = this.unsigned32(this.mt[i] & 0xffffffff);
+ i++;
+ if (i >= this.N) {
+ this.mt[0] = this.mt[this.N - 1];
+ i = 1;
+ }
+ }
+ this.mt[0] = 0x80000000; // MSB is 1; assuring non-zero initial array
+ }
+
+ // moved outside of genrandInt32() by jwatte 2010-11-17; generate less garbage
+ private mag01 = [0x0, this.MATRIX_A];
+
+ /**
+ * Generates a random number on [0,2^32]-interval
+ */
+ genrandInt32(): number {
+ let y: number;
+
+ if (this.mti >= this.N) {
+ // generate N words at one time
+ let kk: number;
+
+ // if initGenrand() has not been called a default initial seed is used
+ if (this.mti === this.N + 1) {
+ this.initGenrand(5489);
+ }
+
+ for (kk = 0; kk < this.N - this.M; kk++) {
+ y = this.unsigned32(
+ (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
+ );
+
+ this.mt[kk] = this.unsigned32(
+ this.mt[kk + this.M] ^ (y >>> 1) ^ this.mag01[y & 0x1]
+ );
+ }
+
+ for (; kk < this.N - 1; kk++) {
+ y = this.unsigned32(
+ (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
+ );
+
+ this.mt[kk] = this.unsigned32(
+ this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ this.mag01[y & 0x1]
+ );
+ }
+
+ y = this.unsigned32(
+ (this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK)
+ );
+
+ this.mt[this.N - 1] = this.unsigned32(
+ this.mt[this.M - 1] ^ (y >>> 1) ^ this.mag01[y & 0x1]
+ );
+
+ this.mti = 0;
+ }
+
+ y = this.mt[this.mti++];
+
+ // Tempering
+ y = this.unsigned32(y ^ (y >>> 11));
+ y = this.unsigned32(y ^ ((y << 7) & 0x9d2c5680));
+ y = this.unsigned32(y ^ ((y << 15) & 0xefc60000));
+ y = this.unsigned32(y ^ (y >>> 18));
+
+ return y;
+ }
+
+ /**
+ * Generates a random number on [0,2^32]-interval
+ */
+ genrandInt31(): number {
+ return this.genrandInt32() >>> 1;
+ }
+
+ /**
+ * Generates a random number on [0,1]-real-interval
+ */
+ genrandReal1(): number {
+ return this.genrandInt32() * (1.0 / 4294967295.0); // divided by 2^32-1
+ }
+
+ /**
+ * Generates a random number on [0,1)-real-interval
+ */
+ genrandReal2(): number {
+ return this.genrandInt32() * (1.0 / 4294967296.0); // divided by 2^32
+ }
+
+ /**
+ * Generates a random number on (0,1)-real-interval
+ */
+ genrandReal3(): number {
+ return (this.genrandInt32() + 0.5) * (1.0 / 4294967296.0); // divided by 2^32
+ }
+
+ /**
+ * Generates a random number on [0,1) with 53-bit resolution
+ */
+ genrandRes53(): number {
+ const a = this.genrandInt32() >>> 5,
+ b = this.genrandInt32() >>> 6;
+ return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
+ }
+ // These real versions are due to Isaku Wada, 2002/01/09
+}
diff --git a/src/vendor/unique.ts b/src/utils/unique.ts
similarity index 96%
rename from src/vendor/unique.ts
rename to src/utils/unique.ts
index 0d6e6317ece..2679b3d86d5 100644
--- a/src/vendor/unique.ts
+++ b/src/utils/unique.ts
@@ -1,3 +1,5 @@
+import { FakerError } from '../errors/faker-error';
+
export type RecordKey = string | number | symbol;
// global results store
@@ -19,7 +21,7 @@ function defaultCompare(
obj: Record,
key: RecordKey
): 0 | -1 {
- if (typeof obj[key] === 'undefined') {
+ if (obj[key] === undefined) {
return -1;
}
return 0;
@@ -41,7 +43,7 @@ function errorMessage(
now - opts.startTime,
'ms'
);
- throw new Error(
+ throw new FakerError(
code +
' for uniqueness check \n\nMay not be able to generate any more unique values with current settings. \nTry adjusting maxTime or maxRetries parameters for faker.unique()'
);
@@ -71,7 +73,7 @@ export function exec RecordKey>(
opts.currentIterations = 0;
}
- if (typeof opts.startTime === 'undefined') {
+ if (opts.startTime == null) {
opts.startTime = new Date().getTime();
}
diff --git a/src/vendor/user-agent.ts b/src/utils/user-agent.ts
similarity index 85%
rename from src/vendor/user-agent.ts
rename to src/utils/user-agent.ts
index 9218c6e51bb..7f7e8cbb9ce 100644
--- a/src/vendor/user-agent.ts
+++ b/src/utils/user-agent.ts
@@ -1,29 +1,45 @@
-/*
+/**
+ * Copyright (c) 2022 Faker
+ *
+ * This is a version of the original code migrated to TypeScript and modified
+ * by the Faker team.
+ *
+ * Check LICENSE for more details about the copyright.
+ *
+ * -----------------------------------------------------------------------------
+ *
* Copyright (c) 2012-2014 Jeffrey Mealo
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
- * Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
*
- * ------------------------------------------------------------------------------------------------------------------------
+ * -----------------------------------------------------------------------------
*
- * Based loosely on Luka Pusic's PHP Script: http://360percents.com/posts/php-random-user-agent-generator/
+ * Based loosely on Luka Pusic's PHP Script:
+ * http://360percents.com/posts/php-random-user-agent-generator/
*
* The license for that script is as follows:
*
* "THE BEER-WARE LICENSE" (Revision 42):
*
- * wrote this file. As long as you retain this notice you can do whatever you want with this stuff.
- * If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Luka Pusic
+ * wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Luka Pusic
*/
import type { Faker } from '..';
diff --git a/src/vehicle.ts b/src/vehicle.ts
index 58fb63a14f2..979631bdddc 100644
--- a/src/vehicle.ts
+++ b/src/vehicle.ts
@@ -1,15 +1,10 @@
import type { Faker } from '.';
-import type { Fake } from './fake';
-
-let fake: Fake['fake'];
/**
* Module to generate vehicle related entries.
*/
export class Vehicle {
constructor(private readonly faker: Faker) {
- fake = faker.fake;
-
// Bind `this` so namespaced is working correctly
for (const name of Object.getOwnPropertyNames(Vehicle.prototype)) {
if (name === 'constructor' || typeof this[name] !== 'function') {
@@ -26,7 +21,7 @@ export class Vehicle {
* faker.vehicle.vehicle() // 'BMW Explorer'
*/
vehicle(): string {
- return fake('{{vehicle.manufacturer}} {{vehicle.model}}');
+ return `${this.manufacturer()} ${this.model()}`;
}
/**
@@ -87,7 +82,7 @@ export class Vehicle {
bannedChars,
})}${this.faker.random.alphaNumeric(1, {
bannedChars,
- })}${this.faker.datatype.number({ min: 10000, max: 100000 })}` // return five digit #
+ })}${this.faker.datatype.number({ min: 10000, max: 99999 })}` // return five digit #
.toUpperCase();
}
@@ -98,7 +93,7 @@ export class Vehicle {
* faker.vehicle.color() // 'red'
*/
color(): string {
- return fake('{{commerce.color}}');
+ return this.faker.commerce.color();
}
/**
diff --git a/src/vendor/mersenne.ts b/src/vendor/mersenne.ts
deleted file mode 100644
index 23e44f2cba8..00000000000
--- a/src/vendor/mersenne.ts
+++ /dev/null
@@ -1,342 +0,0 @@
-// this program is a JavaScript version of Mersenne Twister, with concealment and encapsulation in class,
-// an almost straight conversion from the original program, mt19937ar.c,
-// translated by y. okada on July 17, 2006.
-// and modified a little at july 20, 2006, but there are not any substantial differences.
-// in this program, procedure descriptions and comments of original source code were not removed.
-// lines commented with //c// were originally descriptions of c procedure. and a few following lines are appropriate JavaScript descriptions.
-// lines commented with /* and */ are original comments.
-// lines commented with // are additional comments in this JavaScript version.
-// before using this version, create at least one instance of MersenneTwister19937 class, and initialize the each state, given below in c comments, of all the instances.
-
-/*
- * A C-program for MT19937, with initialization improved 2002/1/26.
- * Coded by Takuji Nishimura and Makoto Matsumoto.
- *
- * Before using, initialize the state by using init_genrand(seed)
- * or init_by_array(init_key, key_length).
- *
- * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *
- * Any feedback is very welcome.
- * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
- * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
- */
-
-export default class MersenneTwister19937 {
- /* constants should be scoped inside the class */
- /* Period parameters */
- //c//#define N 624
- //c//#define M 397
- //c//#define MATRIX_A 0x9908b0dfUL /* constant vector a */
- //c//#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
- //c//#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
- private readonly N = 624;
- private readonly M = 397;
- private readonly MATRIX_A = 0x9908b0df; /* constant vector a */
- private readonly UPPER_MASK = 0x80000000; /* most significant w-r bits */
- private readonly LOWER_MASK = 0x7fffffff; /* least significant r bits */
- //c//static unsigned long mt[N]; /* the array for the state vector */
- //c//static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
- private mt: number[] = new Array(
- this.N
- ); /* the array for the state vector */
- private mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */
-
- /**
- * Returns a 32-bits unsiged integer from an operand to which applied a bit operator.
- *
- * @param n1 number to unsign
- */
- private unsigned32(n1: number): number {
- // returns a 32-bits unsiged integer from an operand to which applied a bit operator.
- return n1 < 0 ? (n1 ^ this.UPPER_MASK) + this.UPPER_MASK : n1;
- }
-
- /**
- * Emulates lowerflow of a c 32-bits unsiged integer variable, instead of the operator -.
- * These both arguments must be non-negative integers expressible using unsigned 32 bits.
- *
- * @param n1 dividend
- * @param n2 divisor
- */
- private subtraction32(n1: number, n2: number): number {
- return n1 < n2
- ? this.unsigned32((0x100000000 - (n2 - n1)) & 0xffffffff)
- : n1 - n2;
- }
-
- /**
- * emulates overflow of a c 32-bits unsiged integer variable, instead of the operator +.
- * these both arguments must be non-negative integers expressible using unsigned 32 bits.
- *
- * @param n1 number one for addition
- * @param n2 number two for addition
- */
- private addition32(n1: number, n2: number): number {
- return this.unsigned32((n1 + n2) & 0xffffffff);
- }
-
- /**
- * Emulates overflow of a c 32-bits unsiged integer variable, instead of the operator *.
- * These both arguments must be non-negative integers expressible using unsigned 32 bits.
- *
- * @param n1 number one for multiplication
- * @param n2 number two for multiplication
- */
- private multiplication32(n1: number, n2: number): number {
- let sum = 0;
- for (let i = 0; i < 32; ++i) {
- if ((n1 >>> i) & 0x1) {
- sum = this.addition32(sum, this.unsigned32(n2 << i));
- }
- }
- return sum;
- }
-
- /**
- * Initializes mt[N] with a seed.
- *
- * @param seed the seed to use
- */
- //c//void init_genrand(unsigned long s)
- initGenrand(seed: number): void {
- //c//mt[0]= s & 0xffffffff;
- this.mt[0] = this.unsigned32(seed & 0xffffffff);
- for (this.mti = 1; this.mti < this.N; this.mti++) {
- this.mt[this.mti] =
- //c//(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
- this.addition32(
- this.multiplication32(
- 1812433253,
- this.unsigned32(
- this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30)
- )
- ),
- this.mti
- );
- /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
- /* In the previous versions, MSBs of the seed affect */
- /* only MSBs of the array mt[]. */
- /* 2002/01/09 modified by Makoto Matsumoto */
- //c//mt[mti] &= 0xffffffff;
- this.mt[this.mti] = this.unsigned32(this.mt[this.mti] & 0xffffffff);
- /* for >32 bit machines */
- }
- }
-
- /**
- * Initialize by an array with array-length.
- *
- * @param initKey is the array for initializing keys
- * @param keyLength is its length
- */
- /* slight change for C++, 2004/2/26 */
- //c//void init_by_array(unsigned long init_key[], int key_length)
- initByArray(initKey: number[], keyLength: number): void {
- //c//init_genrand(19650218);
- this.initGenrand(19650218);
- let i = 1;
- let j = 0;
- let k = this.N > keyLength ? this.N : keyLength;
- for (; k; k--) {
- //c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525))
- //c// + init_key[j] + j; /* non linear */
- this.mt[i] = this.addition32(
- this.addition32(
- this.unsigned32(
- this.mt[i] ^
- this.multiplication32(
- this.unsigned32(this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)),
- 1664525
- )
- ),
- initKey[j]
- ),
- j
- );
- //c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
- this.mt[i] = this.unsigned32(this.mt[i] & 0xffffffff);
- i++;
- j++;
- if (i >= this.N) {
- this.mt[0] = this.mt[this.N - 1];
- i = 1;
- }
- if (j >= keyLength) {
- j = 0;
- }
- }
- for (k = this.N - 1; k; k--) {
- //c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941))
- //c//- i; /* non linear */
- this.mt[i] = this.subtraction32(
- this.unsigned32(
- this.mt[i] ^
- this.multiplication32(
- this.unsigned32(this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)),
- 1566083941
- )
- ),
- i
- );
- //c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
- this.mt[i] = this.unsigned32(this.mt[i] & 0xffffffff);
- i++;
- if (i >= this.N) {
- this.mt[0] = this.mt[this.N - 1];
- i = 1;
- }
- }
- this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
- }
-
- /* moved outside of genrand_int32() by jwatte 2010-11-17; generate less garbage */
- private mag01 = [0x0, this.MATRIX_A];
-
- /**
- * Generates a random number on [0,2^32]-interval
- */
- //c//unsigned long genrand_int32(void)
- genrandInt32(): number {
- //c//unsigned long y;
- //c//static unsigned long mag01[2]={0x0UL, MATRIX_A};
- let y: number;
- /* mag01[x] = x * MATRIX_A for x=0,1 */
-
- if (this.mti >= this.N) {
- /* generate N words at one time */
- //c//int kk;
- let kk: number;
-
- if (this.mti === this.N + 1) {
- /* if init_genrand() has not been called, */
- //c//init_genrand(5489); /* a default initial seed is used */
- this.initGenrand(5489);
- } /* a default initial seed is used */
-
- for (kk = 0; kk < this.N - this.M; kk++) {
- //c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
- //c//mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
- y = this.unsigned32(
- (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
- );
- this.mt[kk] = this.unsigned32(
- this.mt[kk + this.M] ^ (y >>> 1) ^ this.mag01[y & 0x1]
- );
- }
- for (; kk < this.N - 1; kk++) {
- //c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
- //c//mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
- y = this.unsigned32(
- (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
- );
- this.mt[kk] = this.unsigned32(
- this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ this.mag01[y & 0x1]
- );
- }
- //c//y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
- //c//mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
- y = this.unsigned32(
- (this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK)
- );
- this.mt[this.N - 1] = this.unsigned32(
- this.mt[this.M - 1] ^ (y >>> 1) ^ this.mag01[y & 0x1]
- );
- this.mti = 0;
- }
-
- y = this.mt[this.mti++];
-
- /* Tempering */
- //c//y ^= (y >> 11);
- //c//y ^= (y << 7) & 0x9d2c5680;
- //c//y ^= (y << 15) & 0xefc60000;
- //c//y ^= (y >> 18);
- y = this.unsigned32(y ^ (y >>> 11));
- y = this.unsigned32(y ^ ((y << 7) & 0x9d2c5680));
- y = this.unsigned32(y ^ ((y << 15) & 0xefc60000));
- y = this.unsigned32(y ^ (y >>> 18));
-
- return y;
- }
-
- /**
- * Generates a random number on [0,2^32]-interval
- */
- //c//long genrand_int31(void)
- genrandInt31(): number {
- //c//return (genrand_int32()>>1);
- return this.genrandInt32() >>> 1;
- }
-
- /**
- * Generates a random number on [0,1]-real-interval
- */
- //c//double genrand_real1(void)
- genrandReal1(): number {
- //c//return genrand_int32()*(1.0/4294967295.0);
- return this.genrandInt32() * (1.0 / 4294967295.0);
- /* divided by 2^32-1 */
- }
-
- /**
- * Generates a random number on [0,1)-real-interval
- */
- //c//double genrand_real2(void)
- genrandReal2(): number {
- //c//return genrand_int32()*(1.0/4294967296.0);
- return this.genrandInt32() * (1.0 / 4294967296.0);
- /* divided by 2^32 */
- }
-
- /**
- * Generates a random number on (0,1)-real-interval
- */
- //c//double genrand_real3(void)
- genrandReal3(): number {
- //c//return ((genrand_int32()) + 0.5)*(1.0/4294967296.0);
- return (this.genrandInt32() + 0.5) * (1.0 / 4294967296.0);
- /* divided by 2^32 */
- }
-
- /**
- * Generates a random number on [0,1) with 53-bit resolution
- */
- //c//double genrand_res53(void)
- genrandRes53(): number {
- //c//unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
- const a = this.genrandInt32() >>> 5,
- b = this.genrandInt32() >>> 6;
- return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
- }
- /* These real versions are due to Isaku Wada, 2002/01/09 added */
-}
diff --git a/src/word.ts b/src/word.ts
index 4570e96492e..2b1e5e4f2c0 100644
--- a/src/word.ts
+++ b/src/word.ts
@@ -16,9 +16,13 @@ export class Word {
/**
* Returns an adjective of random or optionally specified length.
- * If specified length is unresolvable, returns random adjective.
*
- * @param length The optional length of word to return.
+ * @param length Expected adjective length. If specified length is unresolvable, returns adjective of a random length.
+ *
+ * @example
+ * faker.word.adjective() // 'pungent'
+ * faker.word.adjective(5) // 'slimy'
+ * faker.word.adjective(100) // 'complete'
*/
adjective(length?: number): string {
let wordList = this.faker.definitions.word.adjective;
@@ -38,9 +42,13 @@ export class Word {
/**
* Returns an adverb of random or optionally specified length.
- * If specified length is unresolvable, returns random adverb.
*
- * @param length The optional length of word to return.
+ * @param length Expected adverb length. If specified length is unresolvable, returns adverb of a random length.
+ *
+ * @example
+ * faker.word.adverb() // 'quarrelsomely'
+ * faker.word.adverb(5) // 'madly'
+ * faker.word.adverb(100) // 'sadly'
*/
adverb(length?: number): string {
let wordList = this.faker.definitions.word.adverb;
@@ -60,9 +68,13 @@ export class Word {
/**
* Returns a conjunction of random or optionally specified length.
- * If specified length is unresolvable, returns random conjunction.
*
- * @param length The optional length of word to return.
+ * @param length Expected conjunction length. If specified length is unresolvable, returns conjunction of a random length.
+ *
+ * @example
+ * faker.word.conjunction() // 'in order that'
+ * faker.word.conjunction(5) // 'since'
+ * faker.word.conjunction(100) // 'as long as'
*/
conjunction(length?: number): string {
let wordList = this.faker.definitions.word.conjunction;
@@ -82,9 +94,13 @@ export class Word {
/**
* Returns an interjection of random or optionally specified length.
- * If specified length is unresolvable, returns random interjection.
*
- * @param length The optional length of word to return.
+ * @param length Expected interjection length. If specified length is unresolvable, returns interjection of a random length.
+ *
+ * @example
+ * faker.word.interjection() // 'gah'
+ * faker.word.interjection(5) // 'fooey'
+ * faker.word.interjection(100) // 'yowza'
*/
interjection(length?: number): string {
let wordList = this.faker.definitions.word.interjection;
@@ -104,9 +120,13 @@ export class Word {
/**
* Returns a noun of random or optionally specified length.
- * If specified length is unresolvable, returns random noun.
*
- * @param length The optional length of word to return.
+ * @param length Expected noun length. If specified length is unresolvable, returns noun of a random length.
+ *
+ * @example
+ * faker.word.noun() // 'external'
+ * faker.word.noun(5) // 'front'
+ * faker.word.noun(100) // 'care'
*/
noun(length?: number): string {
let wordList = this.faker.definitions.word.noun;
@@ -126,9 +146,13 @@ export class Word {
/**
* Returns a preposition of random or optionally specified length.
- * If specified length is unresolvable, returns random preposition.
*
- * @param length The optional length of word to return.
+ * @param length Expected preposition length. If specified length is unresolvable, returns preposition of a random length.
+ *
+ * @example
+ * faker.word.preposition() // 'without'
+ * faker.word.preposition(5) // 'abaft'
+ * faker.word.preposition(100) // 'an'
*/
preposition(length?: number): string {
let wordList = this.faker.definitions.word.preposition;
@@ -148,9 +172,13 @@ export class Word {
/**
* Returns a verb of random or optionally specified length.
- * If specified length is unresolvable, returns random verb.
*
- * @param length The optional length of word to return.
+ * @param length Expected verb length. If specified length is unresolvable, returns verb of a random length.
+ *
+ * @example
+ * faker.word.verb() // 'act'
+ * faker.word.verb(5) // 'tinge'
+ * faker.word.verb(100) // 'mess'
*/
verb(length?: number): string {
let wordList = this.faker.definitions.word.verb;
diff --git a/test/address.spec.ts b/test/address.spec.ts
index 729d9190b0f..8007714568a 100644
--- a/test/address.spec.ts
+++ b/test/address.spec.ts
@@ -5,7 +5,7 @@ const seededRuns = [
{
seed: 42,
expectations: {
- city: 'Lake Valentine',
+ city: 'Port Valentine',
cityPrefix: 'West',
citySuffix: 'bury',
cityName: 'Gulfport',
@@ -29,14 +29,15 @@ const seededRuns = [
cardinalDirection: 'East',
cardinalDirectionAbbr: 'E',
timeZone: 'Europe/Amsterdam',
+ nearbyGpsCoordinates: ['-0.0394', '0.0396'],
},
},
{
seed: 1337,
expectations: {
- city: 'South Carmelo',
- cityPrefix: 'East',
- citySuffix: 'berg',
+ city: 'New Carmelo',
+ cityPrefix: 'West',
+ citySuffix: 'boro',
cityName: 'Dubuque',
streetName: 'Carmelo Forks',
streetPrefix: 'a',
@@ -58,14 +59,15 @@ const seededRuns = [
cardinalDirection: 'East',
cardinalDirectionAbbr: 'E',
timeZone: 'Africa/Casablanca',
+ nearbyGpsCoordinates: ['-0.0042', '0.0557'],
},
},
{
seed: 1211,
expectations: {
city: 'La Crosse',
- cityPrefix: 'Port',
- citySuffix: 'side',
+ cityPrefix: 'Fort',
+ citySuffix: 'shire',
cityName: 'Urbana',
streetName: 'Trantow Via',
streetPrefix: 'c',
@@ -87,6 +89,7 @@ const seededRuns = [
cardinalDirection: 'West',
cardinalDirectionAbbr: 'W',
timeZone: 'Asia/Magadan',
+ nearbyGpsCoordinates: ['0.0503', '-0.0242'],
},
},
];
@@ -333,6 +336,17 @@ describe('address', () => {
expect(timeZone).toEqual(expectations.timeZone);
});
});
+
+ describe('nearbyGPSCoordinate()', () => {
+ it('returns expected coordinates', () => {
+ faker.seed(seed);
+
+ // this input is required for all expected results for this function
+ const coordsInput: [number, number] = [0, 0];
+ const coords = faker.address.nearbyGPSCoordinate(coordsInput);
+ expect(coords).toEqual(expectations.nearbyGpsCoordinates);
+ });
+ });
});
}
@@ -381,15 +395,15 @@ describe('address', () => {
faker.locale = 'en_US';
const states = ['IL', 'GA', 'WA'];
- const zipCode1 = faker.address.zipCodeByState(states[0]);
+ const zipCode1 = +faker.address.zipCodeByState(states[0]);
expect(zipCode1).greaterThanOrEqual(60001);
expect(zipCode1).lessThanOrEqual(62999);
- const zipCode2 = faker.address.zipCodeByState(states[1]);
+ const zipCode2 = +faker.address.zipCodeByState(states[1]);
expect(zipCode2).greaterThanOrEqual(30001);
expect(zipCode2).lessThanOrEqual(31999);
- const zipCode3 = faker.address.zipCodeByState(states[2]);
+ const zipCode3 = +faker.address.zipCodeByState(states[2]);
expect(zipCode3).greaterThanOrEqual(98001);
expect(zipCode3).lessThanOrEqual(99403);
});
@@ -411,7 +425,7 @@ describe('address', () => {
it('returns latitude with min and max and default precision', () => {
for (let i = 0; i < 100; i++) {
- const latitude = faker.address.latitude(-5, 5);
+ const latitude = faker.address.latitude(5, -5);
expect(latitude).toBeTypeOf('string');
expect(
diff --git a/test/all_functional.spec.ts b/test/all_functional.spec.ts
index a61661611ee..a307e1fc43b 100644
--- a/test/all_functional.spec.ts
+++ b/test/all_functional.spec.ts
@@ -11,10 +11,6 @@ const IGNORED_MODULES = [
'mersenne',
];
-const IGNORED_METHODS = {
- system: ['directoryPath', 'filePath'], // these are TODOs
-};
-
function isTestableModule(mod: string) {
return IGNORED_MODULES.indexOf(mod) === -1;
}
@@ -23,27 +19,44 @@ function isMethodOf(mod: string) {
return (meth: string) => typeof faker[mod][meth] === 'function';
}
-function isTestableMethod(mod: string) {
- return (meth: string) =>
- !(mod in IGNORED_METHODS && IGNORED_METHODS[mod].indexOf(meth) >= 0);
-}
+const BROKEN_LOCALE_METHODS = {
+ // TODO ST-DDT 2022-03-28: these are TODOs (usually broken locale files)
+ address: {
+ cityPrefix: ['pt_BR', 'pt_PT'],
+ citySuffix: ['pt_PT'],
+ state: ['az', 'cz', 'nb_NO', 'sk'],
+ stateAbbr: ['cz', 'sk'],
+ },
+ company: {
+ companySuffix: ['az'],
+ },
+ name: {
+ prefix: ['az', 'id_ID', 'ru'],
+ suffix: ['az', 'it', 'mk', 'pt_PT', 'ru'],
+ },
+};
-function both(
- pred1: (meth: string) => boolean,
- pred2: (meth: string) => boolean
-): (meth: string) => boolean {
- return (value) => pred1(value) && pred2(value);
+function isWorkingLocaleForMethod(
+ mod: string,
+ meth: string,
+ locale: string
+): boolean {
+ return (BROKEN_LOCALE_METHODS[mod]?.[meth] ?? []).indexOf(locale) === -1;
}
// Basic smoke tests to make sure each method is at least implemented and returns a value.
function modulesList(): { [module: string]: string[] } {
const modules = Object.keys(faker)
+ .sort()
.filter(isTestableModule)
.reduce((result, mod) => {
- result[mod] = Object.keys(faker[mod]).filter(
- both(isMethodOf(mod), isTestableMethod(mod))
- );
+ const methods = Object.keys(faker[mod]).filter(isMethodOf(mod));
+ if (methods.length) {
+ result[mod] = methods;
+ } else {
+ console.log(`Skipping ${mod} - No testable methods`);
+ }
return result;
}, {});
@@ -55,23 +68,29 @@ const modules = modulesList();
describe('functional tests', () => {
for (const locale in faker.locales) {
describe(locale, () => {
- faker.locale = locale;
Object.keys(modules).forEach((module) => {
describe(module, () => {
- // if there is nothing to test, create a dummy test so the test runner doesn't complain
- if (Object.keys(modules[module]).length === 0) {
- it.todo(`${module} was empty`);
- }
-
modules[module].forEach((meth) => {
- it(meth + '()', () => {
+ const testAssertion = () => {
+ faker.locale = locale;
+ // TODO ST-DDT 2022-03-28: Use random seed once there are no more failures
+ faker.seed(1);
const result = faker[module][meth]();
+
if (meth === 'boolean') {
expect(result).toBeTypeOf('boolean');
} else {
expect(result).toBeTruthy();
}
- });
+ };
+
+ if (isWorkingLocaleForMethod(module, meth, locale)) {
+ it(meth + '()', testAssertion);
+ } else {
+ // TODO ST-DDT 2022-03-28: Remove once there are no more failures
+ // We expect a failure here to ensure we remove the exclusions when fixed
+ it.fails(meth + '()', testAssertion);
+ }
});
});
});
@@ -82,26 +101,16 @@ describe('functional tests', () => {
describe('faker.fake functional tests', () => {
for (const locale in faker.locales) {
describe(locale, () => {
- faker.locale = locale;
- faker.seed(1);
Object.keys(modules).forEach((module) => {
describe(module, () => {
- // if there is nothing to test, create a dummy test so the test runner doesn't complain
- if (Object.keys(modules[module]).length === 0) {
- it.todo(`${module} was empty`);
- }
-
modules[module].forEach((meth) => {
it(meth + '()', () => {
+ faker.locale = locale;
+ // TODO ST-DDT 2022-03-28: Use random seed once there are no more failures
+ faker.seed(1);
const result = faker.fake('{{' + module + '.' + meth + '}}');
- // just make sure any result is returned
- // an undefined result usually means an error
- expect(result).toBeDefined();
- // if (meth === 'boolean') {
- // expect(result).toBeTypeOf('boolean');
- // } else {
- // expect(result).toBeTruthy();
- // }
+
+ expect(result).toBeTypeOf('string');
});
});
});
diff --git a/test/commerce.spec.ts b/test/commerce.spec.ts
index a06f96ed909..64c7d7b324d 100644
--- a/test/commerce.spec.ts
+++ b/test/commerce.spec.ts
@@ -10,7 +10,7 @@ const seededRuns = [
productName: 'Fantastic Soft Sausages',
price: '375.00',
productAdjective: 'Fantastic',
- productMaterial: 'Cotton',
+ productMaterial: 'Plastic',
product: 'Pants',
productDescription:
'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design',
@@ -21,9 +21,9 @@ const seededRuns = [
expectations: {
color: 'black',
department: 'Computers',
- productName: 'Gorgeous Rubber Keyboard',
+ productName: 'Incredible Granite Keyboard',
price: '263.00',
- productAdjective: 'Gorgeous',
+ productAdjective: 'Incredible',
productMaterial: 'Concrete',
product: 'Ball',
productDescription:
@@ -35,7 +35,7 @@ const seededRuns = [
expectations: {
color: 'azure',
department: 'Automotive',
- productName: 'Unbranded Granite Salad',
+ productName: 'Unbranded Cotton Salad',
price: '929.00',
productAdjective: 'Unbranded',
productMaterial: 'Frozen',
@@ -121,8 +121,7 @@ describe('commerce', () => {
const price = faker.commerce.price();
expect(price).toBeTruthy();
-
- // TODO @Shinigami92 2022-01-20: I converted the price string to number to satisfy TS
+ expect(price).toBeTypeOf('string');
expect(+price).greaterThan(0);
expect(+price).lessThanOrEqual(1000);
});
@@ -154,8 +153,7 @@ describe('commerce', () => {
const amount = faker.commerce.price(-200, -1);
expect(amount).toBeTruthy();
- // TODO @Shinigami92 2022-01-20: I converted the price string to number to satisfy TS
- expect(+amount === 0.0, 'the amount should equal 0').toBe(true);
+ expect(amount, 'the amount should equal 0').toBe('0');
});
it('should handle argument dec', () => {
diff --git a/test/datatype.spec.ts b/test/datatype.spec.ts
index bee280d7bf1..8c7d572a9ac 100644
--- a/test/datatype.spec.ts
+++ b/test/datatype.spec.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
const seededRuns = [
@@ -8,7 +8,7 @@ const seededRuns = [
number: {
noArgs: 37454,
numbers: [2, 5, 6, 1, 5],
- withMin: 37427,
+ withMin: 37412,
withMinAndMax: -1,
withMax: 26,
withMinAndMaxAndPrecision: -0.43,
@@ -16,14 +16,17 @@ const seededRuns = [
float: {
noArgs: 37453.64,
numbers: [37452, 79656, 95076, 18342, 73200],
- withMin: 37427.37,
+ withMin: 37411.64,
withMinAndMax: -0.43,
withMax: 25.84,
withMinAndMaxAndPrecision: -0.4261,
},
datetime: {
- // TODO @Shinigami92 2022-01-29: We will fix the deterministic in #343
- noArgs: new Date('2092-03-22T16:55:38.644Z'),
+ noArgs: new Date('2031-03-14T21:33:22.114Z'),
+ number: new Date('1994-03-20T17:23:00.629Z'),
+ withMin: new Date('1801-04-11T15:13:06.330Z'),
+ withMax: new Date('1994-07-11T09:43:47.230Z'),
+ withMinMax: new Date('1689-09-09T08:39:09.444Z'),
},
string: {
noArgs: 'Cky2eiXX/J',
@@ -35,7 +38,7 @@ const seededRuns = [
boolean: {
noArgs: false,
},
- hexaDecimal: {
+ hexadecimal: {
noArgs: '0x8',
length: '0x8BE4ABdd39321aD7d3fe01FfCE404F4d6db0906bd8',
},
@@ -77,7 +80,7 @@ const seededRuns = [
number: {
noArgs: 26202,
numbers: [1, 3, 1, 1, 1],
- withMin: 26171,
+ withMin: 26160,
withMinAndMax: -13,
withMax: 18,
withMinAndMaxAndPrecision: -12.92,
@@ -85,14 +88,17 @@ const seededRuns = [
float: {
noArgs: 26202.2,
numbers: [26202, 56052, 15864, 21258, 27810],
- withMin: 26171.21,
+ withMin: 26160.2,
withMinAndMax: -12.92,
withMax: 18.08,
withMinAndMaxAndPrecision: -12.9153,
},
datetime: {
- // TODO @Shinigami92 2022-01-29: We will fix the deterministic in #343
- noArgs: new Date('2092-03-22T16:55:38.644Z'),
+ noArgs: new Date('2018-10-28T08:46:11.896Z'),
+ number: new Date('1992-12-13T04:13:59.232Z'),
+ withMin: new Date('1747-07-16T01:19:54.159Z'),
+ withMax: new Date('1993-03-02T00:10:04.335Z'),
+ withMinMax: new Date('1669-06-22T01:21:21.236Z'),
},
string: {
noArgs: '9U/4:SK$>6',
@@ -104,7 +110,7 @@ const seededRuns = [
boolean: {
noArgs: false,
},
- hexaDecimal: {
+ hexadecimal: {
noArgs: '0x5',
length: '0x5c346ba075bd57F5A62B82d72AF39CBBB07a98cbA8',
},
@@ -146,7 +152,7 @@ const seededRuns = [
number: {
noArgs: 92852,
numbers: [6, 3, 6, 5, 1],
- withMin: 92849,
+ withMin: 92810,
withMinAndMax: 61,
withMax: 64,
withMinAndMaxAndPrecision: 61.07,
@@ -154,14 +160,17 @@ const seededRuns = [
float: {
noArgs: 92851.09,
numbers: [92856, 45900, 89346, 77826, 22554],
- withMin: 92848.09,
+ withMin: 92809.09,
withMinAndMax: 61.07,
withMax: 64.07,
withMinAndMaxAndPrecision: 61.0658,
},
datetime: {
- // TODO @Shinigami92 2022-01-29: We will fix the deterministic in #343
- noArgs: new Date('2092-03-22T16:55:38.644Z'),
+ noArgs: new Date('2092-02-20T03:42:04.341Z'),
+ number: new Date('2000-06-14T02:54:42.082Z'),
+ withMin: new Date('2065-11-10T19:27:20.915Z'),
+ withMax: new Date('2001-03-20T11:14:25.251Z'),
+ withMinMax: new Date('1789-03-26T15:44:45.218Z'),
},
string: {
noArgs: 'wKti5-}$_/',
@@ -173,7 +182,7 @@ const seededRuns = [
boolean: {
noArgs: true,
},
- hexaDecimal: {
+ hexadecimal: {
noArgs: '0xE',
length: '0xEaDB42F0e3f4A973fAB0AeefCE96DFCF49cD438dF9',
},
@@ -220,7 +229,7 @@ const functionNames = [
'string',
'uuid',
'boolean',
- 'hexaDecimal',
+ 'hexadecimal',
'json',
'array',
'bigInt',
@@ -230,17 +239,6 @@ describe('datatype', () => {
for (const { seed, expectations } of seededRuns) {
describe(`seed: ${seed}`, () => {
for (const functionName of functionNames) {
- if (functionName === 'datetime') {
- // TODO @Shinigami92 2022-01-29: We will fix the deterministic in #343
- it(`${functionName}()`, () => {
- faker.seed(seed);
-
- const actual = faker.datatype.datetime();
- expect(actual).toBeTypeOf('object');
- });
- continue;
- }
-
it(`${functionName}()`, () => {
faker.seed(seed);
@@ -290,6 +288,17 @@ describe('datatype', () => {
});
expect(actual).toEqual(expectations.number.withMinAndMaxAndPrecision);
});
+
+ it('should throw when min > max', () => {
+ const min = 10;
+ const max = 9;
+
+ faker.seed(seed);
+
+ expect(() => {
+ faker.datatype.number({ min, max });
+ }).toThrowError(`Max ${max} should be larger then min ${min}`);
+ });
});
describe('float', () => {
@@ -335,10 +344,42 @@ describe('datatype', () => {
});
});
- // TODO @ST-DDT 2022-01-29: #343
- describe.todo('datetime', () => {
- it('should ... ', () => {
+ describe('datetime', () => {
+ it('should return a deterministic date when given a number', () => {
+ faker.seed(seed);
+
+ const actual = faker.datatype.datetime(
+ Date.parse('2001-04-03T23:21:10.773Z')
+ );
+ expect(actual).toEqual(expectations.datetime.number);
+ });
+
+ it('should return a deterministic date when given a min date', () => {
+ faker.seed(seed);
+
+ const actual = faker.datatype.datetime({
+ min: Date.parse('1622-05-23T13:45:08.843Z'),
+ });
+ expect(actual).toEqual(expectations.datetime.withMin);
+ });
+
+ it('should return a deterministic date when given a max date', () => {
+ faker.seed(seed);
+
+ const actual = faker.datatype.datetime({
+ max: Date.parse('2002-01-29T19:47:52.605Z'),
+ });
+ expect(actual).toEqual(expectations.datetime.withMax);
+ });
+
+ it('should return a deterministic date when given a min and max date', () => {
faker.seed(seed);
+
+ const actual = faker.datatype.datetime({
+ min: Date.parse('1622-05-23T13:45:08.843Z'),
+ max: Date.parse('1802-01-29T19:47:52.605Z'),
+ });
+ expect(actual).toEqual(expectations.datetime.withMinMax);
});
});
@@ -351,12 +392,12 @@ describe('datatype', () => {
});
});
- describe('hexaDecimal', () => {
+ describe('hexadecimal', () => {
it('should return a deterministic hex of given length', () => {
faker.seed(seed);
- const actual = faker.datatype.hexaDecimal(42);
- expect(actual).toEqual(expectations.hexaDecimal.length);
+ const actual = faker.datatype.hexadecimal(42);
+ expect(actual).toEqual(expectations.hexadecimal.length);
});
});
@@ -445,18 +486,27 @@ describe('datatype', () => {
}
});
- it('should not modify the input object', () => {
- const min = 1;
- const max = 2;
- const opts = {
- min: min,
- max: max,
+ it('should not mutate the input object', () => {
+ const initalMin = 1;
+ const initalPrecision = 1;
+ const initalOtherProperty = 'hello darkness my old friend';
+ const input: {
+ min?: number;
+ max?: number;
+ precision?: number;
+ otherProperty: string;
+ } = {
+ min: initalMin,
+ precision: initalPrecision,
+ otherProperty: initalOtherProperty,
};
- faker.datatype.number(opts);
+ faker.datatype.number(input);
- expect(opts.min).toBe(min);
- expect(opts.max).toBe(max);
+ expect(input.min).toBe(initalMin);
+ expect(input.precision).toBe(initalPrecision);
+ expect(input.max).toBe(undefined);
+ expect(input.otherProperty).toBe(initalOtherProperty);
});
});
@@ -579,14 +629,38 @@ describe('datatype', () => {
});
describe('hexaDecimal', () => {
+ it('should display deprecated message', () => {
+ const spy = vi.spyOn(console, 'warn');
+
+ faker.datatype.hexaDecimal();
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.datatype.hexaDecimal() is deprecated since v6.1.2 and will be removed in v7.0.0. Please use faker.datatype.hexadecimal() instead.'
+ );
+
+ spy.mockRestore();
+ });
+
+ it('should display call hexadecimal()', () => {
+ const spy = vi.spyOn(faker.datatype, 'hexadecimal');
+
+ faker.datatype.hexaDecimal(10);
+
+ expect(spy).toHaveBeenCalledWith(10);
+
+ spy.mockRestore();
+ });
+ });
+
+ describe('hexadecimal', () => {
it('generates single hex character when no additional argument was provided', () => {
- const hex = faker.datatype.hexaDecimal();
+ const hex = faker.datatype.hexadecimal();
expect(hex).match(/^(0x)[0-9a-f]{1}$/i);
expect(hex.substring(2)).toHaveLength(1);
});
it('generates a random hex string', () => {
- const hex = faker.datatype.hexaDecimal(5);
+ const hex = faker.datatype.hexadecimal(5);
expect(hex).match(/^(0x)[0-9a-f]+$/i);
expect(hex.substring(2)).toHaveLength(5);
});
diff --git a/test/date.spec.ts b/test/date.spec.ts
index a6af2cb5d00..99141a89476 100644
--- a/test/date.spec.ts
+++ b/test/date.spec.ts
@@ -5,50 +5,30 @@ const seededRuns = [
{
seed: 42,
expectations: {
- past: [
- new Date('2020-10-08T00:10:58.041Z'),
- new Date('2020-10-08T00:10:57.330Z'),
- new Date('2017-05-26T15:26:24.637Z'),
- new Date('2017-05-26T15:26:23.926Z'),
- ],
- future: [
- new Date('2021-07-08T10:07:33.381Z'),
- new Date('2021-07-08T10:07:32.670Z'),
- new Date('2024-11-19T18:52:06.785Z'),
- new Date('2024-11-19T18:52:06.074Z'),
- ],
- between: [
- new Date('2021-03-15T19:30:57.091Z'),
- new Date('2021-07-29T19:19:12.731Z'),
- ],
+ past: {
+ noArgs: new Date('2020-10-08T00:10:58.041Z'),
+ ten: new Date('2017-05-26T15:26:24.637Z'),
+ },
+ future: {
+ noArgs: new Date('2021-07-08T10:07:33.381Z'),
+ ten: new Date('2024-11-19T18:52:06.785Z'),
+ },
+ between: new Date('2021-03-15T19:30:57.091Z'),
betweens: [
- [
- new Date('2021-03-08T11:09:46.211Z'),
- new Date('2021-03-23T05:10:16.500Z'),
- new Date('2021-04-06T23:10:46.500Z'),
- ],
- [
- new Date('2021-03-08T11:09:45.500Z'),
- new Date('2021-03-23T05:10:15.500Z'),
- new Date('2021-04-06T23:10:45.500Z'),
- ],
- ],
- recent: [
- new Date('2021-02-21T08:11:56.820Z'),
- new Date('2021-02-21T08:11:56.109Z'),
- ],
- soon: [
- new Date('2021-03-13T23:15:38.042Z'),
- new Date('2021-03-13T23:15:37.891Z'),
+ new Date('2021-03-15T19:30:57.091Z'),
+ new Date('2021-04-09T17:05:10.406Z'),
+ new Date('2021-04-18T19:23:52.973Z'),
],
+ recent: new Date('2021-02-21T08:11:56.820Z'),
+ soon: new Date('2021-03-13T23:15:38.042Z'),
month: {
- default: 'May',
+ noArgs: 'May',
abbr: 'May',
context: 'May',
abbr_context: 'May',
},
weekday: {
- default: 'Tuesday',
+ noArgs: 'Tuesday',
abbr: 'Tue',
context: 'Tuesday',
abbr_context: 'Tue',
@@ -58,50 +38,30 @@ const seededRuns = [
{
seed: 1337,
expectations: {
- past: [
- new Date('2020-11-18T01:49:04.785Z'),
- new Date('2020-11-18T01:49:04.074Z'),
- new Date('2018-07-11T07:47:33.089Z'),
- new Date('2018-07-11T07:47:32.378Z'),
- ],
- future: [
- new Date('2021-05-28T08:29:26.637Z'),
- new Date('2021-05-28T08:29:25.926Z'),
- new Date('2023-10-06T02:30:58.333Z'),
- new Date('2023-10-06T02:30:57.622Z'),
- ],
- between: [
- new Date('2021-03-09T04:11:24.667Z'),
- new Date('2021-06-12T02:21:47.178Z'),
- ],
+ past: {
+ noArgs: new Date('2020-11-18T01:49:04.785Z'),
+ ten: new Date('2018-07-11T07:47:33.089Z'),
+ },
+ future: {
+ noArgs: new Date('2021-05-28T08:29:26.637Z'),
+ ten: new Date('2023-10-06T02:30:58.333Z'),
+ },
+ between: new Date('2021-03-09T04:11:24.667Z'),
betweens: [
- [
- new Date('2021-03-08T11:09:46.211Z'),
- new Date('2021-03-23T05:10:16.500Z'),
- new Date('2021-04-06T23:10:46.500Z'),
- ],
- [
- new Date('2021-03-08T11:09:45.500Z'),
- new Date('2021-03-23T05:10:15.500Z'),
- new Date('2021-04-06T23:10:45.500Z'),
- ],
- ],
- recent: [
- new Date('2021-02-21T10:53:58.041Z'),
- new Date('2021-02-21T10:53:57.330Z'),
- ],
- soon: [
- new Date('2021-03-13T20:33:36.821Z'),
- new Date('2021-03-13T20:33:36.670Z'),
+ new Date('2021-03-03T01:51:22.512Z'),
+ new Date('2021-03-09T04:11:24.667Z'),
+ new Date('2021-03-26T18:53:00.564Z'),
],
+ recent: new Date('2021-02-21T10:53:58.041Z'),
+ soon: new Date('2021-03-13T20:33:36.821Z'),
month: {
- default: 'April',
+ noArgs: 'April',
abbr: 'Apr',
context: 'April',
abbr_context: 'Apr',
},
weekday: {
- default: 'Monday',
+ noArgs: 'Monday',
abbr: 'Mon',
context: 'Monday',
abbr_context: 'Mon',
@@ -111,50 +71,30 @@ const seededRuns = [
{
seed: 1211,
expectations: {
- past: [
- new Date('2020-03-19T19:19:04.071Z'),
- new Date('2020-03-19T19:19:03.360Z'),
- new Date('2011-11-12T14:47:19.955Z'),
- new Date('2011-11-12T14:47:19.244Z'),
- ],
- future: [
- new Date('2022-01-26T14:59:27.351Z'),
- new Date('2022-01-26T14:59:26.640Z'),
- new Date('2030-06-03T19:31:11.467Z'),
- new Date('2030-06-03T19:31:10.756Z'),
- ],
- between: [
- new Date('2021-04-17T11:58:13.327Z'),
- new Date('2022-03-21T16:37:15.905Z'),
- ],
+ past: {
+ noArgs: new Date('2020-03-19T19:19:04.071Z'),
+ ten: new Date('2011-11-12T14:47:19.955Z'),
+ },
+ future: {
+ noArgs: new Date('2022-01-26T14:59:27.351Z'),
+ ten: new Date('2030-06-03T19:31:11.467Z'),
+ },
+ between: new Date('2021-04-17T11:58:13.327Z'),
betweens: [
- [
- new Date('2021-03-08T11:09:46.211Z'),
- new Date('2021-03-23T05:10:16.500Z'),
- new Date('2021-04-06T23:10:46.500Z'),
- ],
- [
- new Date('2021-03-08T11:09:45.500Z'),
- new Date('2021-03-23T05:10:15.500Z'),
- new Date('2021-04-06T23:10:45.500Z'),
- ],
- ],
- recent: [
- new Date('2021-02-20T18:54:13.498Z'),
- new Date('2021-02-20T18:54:12.787Z'),
- ],
- soon: [
- new Date('2021-03-14T12:33:21.364Z'),
- new Date('2021-03-14T12:33:21.213Z'),
+ new Date('2021-03-20T19:08:07.621Z'), // done
+ new Date('2021-04-15T10:20:25.794Z'),
+ new Date('2021-04-17T11:58:13.327Z'),
],
+ recent: new Date('2021-02-20T18:54:13.498Z'),
+ soon: new Date('2021-03-14T12:33:21.364Z'),
month: {
- default: 'December',
+ noArgs: 'December',
abbr: 'Dec',
context: 'December',
abbr_context: 'Dec',
},
weekday: {
- default: 'Saturday',
+ noArgs: 'Saturday',
abbr: 'Sat',
context: 'Saturday',
abbr_context: 'Sat',
@@ -163,6 +103,12 @@ const seededRuns = [
},
];
+const converterMap = [
+ (d: Date) => d,
+ (d: Date) => d.toISOString(),
+ (d: Date) => d.valueOf(),
+];
+
const NON_SEEDED_BASED_RUN = 5;
describe('date', () => {
@@ -178,7 +124,7 @@ describe('date', () => {
const actual = faker.date.past(undefined, '2021-02-21T17:09:15.711Z');
- expect(actual).toEqual(expectations.past[0]);
+ expect(actual).toEqual(expectations.past.noArgs);
});
it('should return deterministic past value on given refDate of type date', () => {
@@ -189,7 +135,7 @@ describe('date', () => {
new Date('2021-02-21T17:09:15.711Z')
);
- expect(actual).toEqual(expectations.past[1]);
+ expect(actual).toEqual(expectations.past.noArgs);
});
it('should return deterministic past value on given years 10 and refDate of type string', () => {
@@ -197,7 +143,7 @@ describe('date', () => {
const actual = faker.date.past(10, '2021-02-21T17:09:15.711Z');
- expect(actual).toEqual(expectations.past[2]);
+ expect(actual).toEqual(expectations.past.ten);
});
it('should return deterministic past value on given years 10 and refDate of type date', () => {
@@ -208,7 +154,7 @@ describe('date', () => {
new Date('2021-02-21T17:09:15.711Z')
);
- expect(actual).toEqual(expectations.past[3]);
+ expect(actual).toEqual(expectations.past.ten);
});
});
@@ -221,7 +167,7 @@ describe('date', () => {
'2021-02-21T17:09:15.711Z'
);
- expect(actual).toEqual(expectations.future[0]);
+ expect(actual).toEqual(expectations.future.noArgs);
});
it('should return deterministic future value on given refDate of type date', () => {
@@ -232,7 +178,7 @@ describe('date', () => {
new Date('2021-02-21T17:09:15.711Z')
);
- expect(actual).toEqual(expectations.future[1]);
+ expect(actual).toEqual(expectations.future.noArgs);
});
it('should return deterministic future value on given years 10 and refDate of type string', () => {
@@ -240,7 +186,7 @@ describe('date', () => {
const actual = faker.date.future(10, '2021-02-21T17:09:15.711Z');
- expect(actual).toEqual(expectations.future[2]);
+ expect(actual).toEqual(expectations.future.ten);
});
it('should return deterministic future value on given years 10 and refDate of type date', () => {
@@ -251,7 +197,7 @@ describe('date', () => {
new Date('2021-02-21T17:09:15.711Z')
);
- expect(actual).toEqual(expectations.future[3]);
+ expect(actual).toEqual(expectations.future.ten);
});
});
@@ -264,18 +210,18 @@ describe('date', () => {
'2021-04-21T17:11:17.711Z'
);
- expect(actual).toEqual(expectations.between[0]);
+ expect(actual).toEqual(expectations.between);
});
it('should return deterministic value between given real dates', () => {
faker.seed(seed);
const actual = faker.date.between(
- new Date('2021-02-21'),
- new Date('2022-04-21')
+ new Date('2021-02-21T17:09:15.711Z'),
+ new Date('2021-04-21T17:11:17.711Z')
);
- expect(actual).toEqual(expectations.between[1]);
+ expect(actual).toEqual(expectations.between);
});
});
@@ -283,25 +229,23 @@ describe('date', () => {
it('should return deterministic value betweens given string dates', () => {
faker.seed(seed);
- // TODO @Shinigami92 2022-01-27: This function doesn't respect seeding
const actual = faker.date.betweens(
'2021-02-21T17:09:15.711Z',
'2021-04-21T17:11:17.711Z'
);
- expect(actual).toEqual(expectations.betweens[0]);
+ expect(actual).toEqual(expectations.betweens);
});
it('should return deterministic value betweens given dates', () => {
faker.seed(seed);
- // TODO @Shinigami92 2022-01-27: This function doesn't respect seeding
const actual = faker.date.betweens(
new Date('2021-02-21T17:09:15.711Z'),
new Date('2021-04-21T17:11:17.711Z')
);
- expect(actual).toEqual(expectations.betweens[1]);
+ expect(actual).toEqual(expectations.betweens);
});
});
@@ -314,7 +258,7 @@ describe('date', () => {
'2021-02-21T17:11:17.711Z'
);
- expect(actual).toEqual(expectations.recent[0]);
+ expect(actual).toEqual(expectations.recent);
});
it('should return deterministic value recent to given refDate of type date', () => {
@@ -325,7 +269,7 @@ describe('date', () => {
new Date('2021-02-21T17:11:17.711Z')
);
- expect(actual).toEqual(expectations.recent[1]);
+ expect(actual).toEqual(expectations.recent);
});
});
@@ -335,7 +279,7 @@ describe('date', () => {
const actual = faker.date.soon(undefined, '2021-03-13T14:16:17.151Z');
- expect(actual).toEqual(expectations.soon[0]);
+ expect(actual).toEqual(expectations.soon);
});
it('should return deterministic value soon to given refDate of type date', () => {
@@ -346,7 +290,7 @@ describe('date', () => {
new Date('2021-03-13T14:16:17.151Z')
);
- expect(actual).toEqual(expectations.soon[1]);
+ expect(actual).toEqual(expectations.soon);
});
});
@@ -356,7 +300,7 @@ describe('date', () => {
const actual = faker.date.month();
- expect(actual).toEqual(expectations.month.default);
+ expect(actual).toEqual(expectations.month.noArgs);
});
it('should return deterministic value month with abbr true', () => {
@@ -390,7 +334,7 @@ describe('date', () => {
const actual = faker.date.weekday();
- expect(actual).toEqual(expectations.weekday.default);
+ expect(actual).toEqual(expectations.weekday.noArgs);
});
it('should return deterministic value weekday with abbr true', () => {
@@ -446,20 +390,18 @@ describe('date', () => {
expect(date).lessThan(refDate);
});
- it('should return a past date relative to given refDate', () => {
- const refDate = new Date();
- refDate.setFullYear(refDate.getFullYear() + 5);
-
- let date = faker.date.past(5, refDate);
-
- expect(date).lessThan(refDate);
- expect(date).greaterThan(new Date());
+ it.each(converterMap)(
+ 'should return a past date relative to given refDate',
+ (converter) => {
+ const refDate = new Date();
+ refDate.setFullYear(refDate.getFullYear() + 5);
- date = faker.date.past(5, refDate.toISOString());
+ const date = faker.date.past(5, converter(refDate));
- expect(date).lessThan(refDate);
- expect(date).greaterThan(new Date());
- });
+ expect(date).lessThan(refDate);
+ expect(date).greaterThan(new Date());
+ }
+ );
});
describe('future()', () => {
@@ -476,41 +418,50 @@ describe('date', () => {
expect(date).greaterThan(refDate); // date should be after the date given
});
- it('should return a date 75 years after the date given', () => {
- const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
+ it.each(converterMap)(
+ 'should return a date 75 years after the date given',
+ (converter) => {
+ const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
- const date = faker.date.future(75, refDate.toISOString());
+ const date = faker.date.future(75, converter(refDate));
- // date should be after the date given, but before the current time
- expect(date).greaterThan(refDate);
- expect(date).lessThan(new Date());
- });
+ // date should be after the date given, but before the current time
+ expect(date).greaterThan(refDate);
+ expect(date).lessThan(new Date());
+ }
+ );
});
describe('between()', () => {
- it('should return a random date between the dates given', () => {
- const from = new Date(1990, 5, 7, 9, 11, 0, 0);
- const to = new Date(2000, 6, 8, 10, 12, 0, 0);
-
- const date = faker.date.between(from, to);
-
- expect(date).greaterThan(from);
- expect(date).lessThan(to);
- });
+ it.each(converterMap)(
+ 'should return a random date between the dates given',
+ (converter) => {
+ const from = new Date(1990, 5, 7, 9, 11, 0, 0);
+ const to = new Date(2000, 6, 8, 10, 12, 0, 0);
+
+ const date = faker.date.between(converter(from), converter(to));
+
+ expect(date).greaterThan(from);
+ expect(date).lessThan(to);
+ }
+ );
});
describe('betweens()', () => {
- it('should return an array of 3 dates ( by default ) of sorted randoms dates between the dates given', () => {
- const from = new Date(1990, 5, 7, 9, 11, 0, 0);
- const to = new Date(2000, 6, 8, 10, 12, 0, 0);
-
- const dates = faker.date.betweens(from, to);
-
- expect(dates[0]).greaterThan(from);
- expect(dates[0]).lessThan(to);
- expect(dates[1]).greaterThan(dates[0]);
- expect(dates[2]).greaterThan(dates[1]);
- });
+ it.each(converterMap)(
+ 'should return an array of 3 dates ( by default ) of sorted randoms dates between the dates given',
+ (converter) => {
+ const from = new Date(1990, 5, 7, 9, 11, 0, 0);
+ const to = new Date(2000, 6, 8, 10, 12, 0, 0);
+
+ const dates = faker.date.betweens(converter(from), converter(to));
+
+ expect(dates[0]).greaterThan(from);
+ expect(dates[0]).lessThan(to);
+ expect(dates[1]).greaterThan(dates[0]);
+ expect(dates[2]).greaterThan(dates[1]);
+ }
+ );
});
describe('recent()', () => {
@@ -520,25 +471,28 @@ describe('date', () => {
expect(date).lessThanOrEqual(new Date());
});
- it('should return a date N days from the recent past, starting from refDate', () => {
- const days = 30;
- const refDate = new Date(2120, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
-
- const date = faker.date.recent(days, refDate);
-
- const lowerBound = new Date(
- refDate.getTime() - days * 24 * 60 * 60 * 1000
- );
-
- expect(
- lowerBound,
- '`recent()` date should not be further back than `n` days ago'
- ).lessThanOrEqual(date);
- expect(
- date,
- '`recent()` date should not be ahead of the starting date reference'
- ).lessThanOrEqual(refDate);
- });
+ it.each(converterMap)(
+ 'should return a date N days from the recent past, starting from refDate',
+ (converter) => {
+ const days = 30;
+ const refDate = new Date(2120, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
+
+ const lowerBound = new Date(
+ refDate.getTime() - days * 24 * 60 * 60 * 1000
+ );
+
+ const date = faker.date.recent(days, converter(refDate));
+
+ expect(
+ lowerBound,
+ '`recent()` date should not be further back than `n` days ago'
+ ).lessThanOrEqual(date);
+ expect(
+ date,
+ '`recent()` date should not be ahead of the starting date reference'
+ ).lessThanOrEqual(refDate);
+ }
+ );
});
describe('soon()', () => {
@@ -548,25 +502,28 @@ describe('date', () => {
expect(date).greaterThanOrEqual(new Date());
});
- it('should return a date N days from the recent future, starting from refDate', () => {
- const days = 30;
- const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
-
- const date = faker.date.soon(days, refDate);
-
- const upperBound = new Date(
- refDate.getTime() + days * 24 * 60 * 60 * 1000
- );
-
- expect(
- date,
- '`soon()` date should not be further ahead than `n` days ago'
- ).lessThanOrEqual(upperBound);
- expect(
- refDate,
- '`soon()` date should not be behind the starting date reference'
- ).lessThanOrEqual(date);
- });
+ it.each(converterMap)(
+ 'should return a date N days from the recent future, starting from refDate',
+ (converter) => {
+ const days = 30;
+ const refDate = new Date(1880, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
+
+ const upperBound = new Date(
+ refDate.getTime() + days * 24 * 60 * 60 * 1000
+ );
+
+ const date = faker.date.soon(days, converter(refDate));
+
+ expect(
+ date,
+ '`soon()` date should not be further ahead than `n` days ago'
+ ).lessThanOrEqual(upperBound);
+ expect(
+ refDate,
+ '`soon()` date should not be behind the starting date reference'
+ ).lessThanOrEqual(date);
+ }
+ );
});
describe('month()', () => {
diff --git a/test/fake.spec.ts b/test/fake.spec.ts
index c8223585771..bf6a2509fca 100644
--- a/test/fake.spec.ts
+++ b/test/fake.spec.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import { faker } from '../src';
+import { FakerError } from '../src/errors/faker-error';
describe('fake', () => {
describe('fake()', () => {
@@ -30,21 +31,59 @@ describe('fake', () => {
it('does not allow undefined parameters', () => {
expect(() =>
- // @ts-expect-error
+ // @ts-expect-error: The parameter is required
faker.fake()
- ).toThrowError(Error('string parameter is required!'));
+ ).toThrowError(new FakerError('string parameter is required!'));
});
it('does not allow invalid module name', () => {
expect(() => faker.fake('{{foo.bar}}')).toThrowError(
- Error('Invalid module: foo')
+ new FakerError('Invalid module: foo')
);
});
it('does not allow invalid method name', () => {
expect(() => faker.fake('{{address.foo}}')).toThrowError(
- Error('Invalid method: address.foo')
+ new FakerError('Invalid method: address.foo')
);
});
+
+ it('should be able to return empty strings', () => {
+ expect(faker.fake('{{helpers.repeatString}}')).toBe('');
+ });
+
+ it('should be able to handle only {{ brackets', () => {
+ expect(faker.fake('{{hello')).toBe('{{hello');
+ expect(faker.fake('hello{{')).toBe('hello{{');
+ });
+
+ it('should be able to handle only }} brackets', () => {
+ expect(faker.fake('hello}}')).toBe('hello}}');
+ expect(faker.fake('}}hello')).toBe('}}hello');
+ });
+
+ it('should be able to handle reverted brackets', () => {
+ expect(faker.fake('}}hello{{')).toBe('}}hello{{');
+ });
+
+ it('should be able to handle random }} brackets', () => {
+ expect(faker.fake('}}hello{{random.alpha}}')).toMatch(/^}}hello[a-z]$/);
+ });
+
+ it('should be able to handle connected brackets', () => {
+ expect(faker.fake('{{{random.alpha}}}')).toMatch(/^{[a-z]}$/);
+ });
+
+ it('should be able to handle empty brackets', () => {
+ expect(faker.fake('{{}}')).toBe('{{}}');
+ });
+
+ it('should be able to handle special replacement patterns', () => {
+ (faker.random as any).special = () => '$&';
+
+ expect(faker.fake('{{random.special}}')).toBe('$&');
+
+ delete (faker.random as any).special;
+ });
});
});
diff --git a/test/faker.spec.ts b/test/faker.spec.ts
new file mode 100644
index 00000000000..983a31bd9b4
--- /dev/null
+++ b/test/faker.spec.ts
@@ -0,0 +1,72 @@
+import { beforeEach, describe, expect, it } from 'vitest';
+import { faker, Faker } from '../src';
+import { FakerError } from '../src/errors/faker-error';
+
+describe('faker', () => {
+ beforeEach(() => {
+ faker.locale = 'en';
+ });
+
+ it('should throw error if no options passed', () => {
+ expect(
+ () =>
+ // @ts-expect-error: mission options
+ new Faker()
+ ).toThrow(
+ new FakerError(
+ 'Options with at least one entry in locales must be provided'
+ )
+ );
+ });
+
+ it('should throw error if no locales passed', () => {
+ expect(
+ () =>
+ // @ts-expect-error: missing locales
+ new Faker({})
+ ).toThrow(
+ new FakerError(
+ 'At least one entry in locales must be provided in the locales parameter'
+ )
+ );
+ });
+
+ describe('title', () => {
+ it.each(Object.keys(faker.locales))('title (%s)', (locale) => {
+ faker.locale = locale;
+ expect(faker.definitions.title).toBe(faker.locales[locale].title);
+ });
+ });
+
+ describe('separator', () => {
+ it.each(Object.keys(faker.locales))('separator (%s)', (locale) => {
+ faker.locale = locale;
+ expect(faker.definitions.separator).toBeTypeOf('string');
+ });
+
+ it('separator (with fallback)', () => {
+ // Use a language that doesn't have a separator specified
+ expect(faker.locales['en_US'].separator).toBeUndefined();
+ // Check that the fallback works
+ expect(faker.definitions.separator).toBe(faker.locales['en'].separator);
+ });
+ });
+
+ // This is only here for coverage
+ // The actual test is in mersenne.spec.ts
+ describe('seed()', () => {
+ it('seed(number)', () => {
+ faker.seed(1);
+
+ const actual = faker.animal.cat();
+ expect(actual).toBe('Korat');
+ });
+
+ it('seed(number[])', () => {
+ faker.seed([1, 2, 3]);
+
+ const actual = faker.animal.cat();
+ expect(actual).toBe('Oriental');
+ });
+ });
+});
diff --git a/test/finance.spec.ts b/test/finance.spec.ts
index 227184c148d..ce529fe2951 100644
--- a/test/finance.spec.ts
+++ b/test/finance.spec.ts
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
+import { FakerError } from '../src/errors/faker-error';
import ibanLib from '../src/iban';
import { luhnCheck } from './support/luhnCheck';
@@ -45,7 +46,7 @@ const seedRuns = [
creditCardCVV: '251',
ethereumAddress: '0x5c346ba075bd57f5a62b82d72af39cbbb07a98cb',
iban: 'FO7710540350900318',
- bic: 'OEFELTL1032',
+ bic: 'OEFELYL1032',
transactionDescription:
'deposit transaction at Cronin - Effertz using card ending with ***(...1830) for PEN 262.02 in account ***55239273',
},
@@ -186,10 +187,7 @@ describe('finance', () => {
it('should set a specified length', () => {
let expected = faker.datatype.number(20);
- expected =
- expected === 0 || !expected || typeof expected === 'undefined'
- ? 4
- : expected;
+ expected = expected || 4;
const mask = faker.finance.mask(expected, false, false); //the length of mask picks 4 if the random number generator picks 0
@@ -205,6 +203,7 @@ describe('finance', () => {
const amount = faker.finance.amount();
expect(amount).toBeTruthy();
+ expect(amount).toBeTypeOf('string');
expect(+amount, 'the amount should be greater than 0').greaterThan(0);
expect(+amount, 'the amount should be less than 1001').lessThan(1001);
});
@@ -234,6 +233,7 @@ describe('finance', () => {
const amount = faker.finance.amount(-200, -1);
expect(amount).toBeTruthy();
+ expect(amount).toBeTypeOf('string');
expect(+amount, 'the amount should be less than 0').lessThan(0);
expect(+amount, 'the amount should be greater than -201').greaterThan(
-201
@@ -384,6 +384,18 @@ describe('finance', () => {
expect(luhnCheck(faker.finance.creditCardNumber())).toBeTruthy();
});
+ it('should ignore case for provider', () => {
+ const seed = faker.seedValue;
+
+ faker.seed(seed);
+ const actualNonLowerCase = faker.finance.creditCardNumber('ViSa');
+
+ faker.seed(seed);
+ const actualLowerCase = faker.finance.creditCardNumber('visa');
+
+ expect(actualNonLowerCase).toBe(actualLowerCase);
+ });
+
it('should return a correct credit card number when issuer provided', () => {
//TODO: implement checks for each format with regexp
const visa = faker.finance.creditCardNumber('visa');
@@ -417,7 +429,7 @@ describe('finance', () => {
expect(luhnCheck(instapayment)).toBeTruthy();
});
- it('should return custom formated strings', () => {
+ it('should return custom formatted strings', () => {
let number = faker.finance.creditCardNumber('###-###-##L');
expect(number).match(/^\d{3}\-\d{3}\-\d{3}$/);
expect(luhnCheck(number)).toBeTruthy();
@@ -473,11 +485,17 @@ describe('finance', () => {
).toStrictEqual(1);
});
- it('throws an error if the passed country code is not supported', () => {
- expect(() => faker.finance.iban(false, 'AA')).toThrowError(
- Error('Country code AA not supported.')
- );
- });
+ it.each(['AA', 'EU'])(
+ 'throws an error for unsupported country code "%s"',
+ (unsupportedCountryCode) =>
+ expect(() =>
+ faker.finance.iban(false, unsupportedCountryCode)
+ ).toThrowError(
+ new FakerError(
+ `Country code ${unsupportedCountryCode} not supported.`
+ )
+ )
+ );
});
describe('bic()', () => {
diff --git a/test/finance_iban.spec.ts b/test/finance_iban.spec.ts
index 23768387d85..6caaa1a2c23 100644
--- a/test/finance_iban.spec.ts
+++ b/test/finance_iban.spec.ts
@@ -9,6 +9,20 @@ describe('finance_iban', () => {
// Create and log-back the seed for debug purposes
faker.seed(Math.ceil(Math.random() * 1_000_000_000));
+ describe('generic IBAN country checks', () => {
+ it.each(
+ faker.finance.ibanLib.formats.map(
+ (entry) => entry.country as string
+ ) as string[]
+ )('%s', (country) => {
+ expect(country).toMatch(/^[A-Z]{2}$/);
+ const actual = faker.finance.iban(true, country);
+
+ expect(actual).toMatch(new RegExp(`^${country}`));
+ expect(actual).satisfy(validator.isIBAN);
+ });
+ });
+
describe(`random seeded tests for seed ${JSON.stringify(
faker.seedValue
)}`, () => {
@@ -255,6 +269,85 @@ describe('finance_iban', () => {
'the result should be equal to 1'
).toBe(1);
});
+
+ it('IBAN for Costa Rica is correct', () => {
+ // Costa Rica
+ // https://wise.com/us/iban/costa-rica
+ // Length 22
+ // BBAN 1n,3n,14n
+ // CRkk xbbb cccc cccc cccc cccc cccc
+ // x = reserve digit
+ // b = National bank code (digits)
+ // c = Account number (digits)
+
+ // example IBAN CR05 0152 0200 1026 2840 66
+
+ const iban = faker.finance.iban(false, 'CR');
+
+ expect(iban).satisfy(validator.isIBAN);
+
+ const ibanFormated = iban.match(/.{1,4}/g).join(' ');
+ const bban = iban.substring(4) + iban.substring(0, 4);
+
+ expect(
+ 22,
+ `CR IBAN would be 22 chars length, given is ${iban.length}`
+ ).toBe(iban.length);
+
+ expect(
+ iban.substring(0, 2),
+ iban.substring(0, 2) +
+ "must start with 'CR' in CR IBAN " +
+ ibanFormated
+ ).to.eq('CR');
+
+ expect(
+ iban.substring(2, 22),
+ iban.substring(2, 22) +
+ ' must contains only digit in AZ IBAN ' +
+ ibanFormated
+ ).match(/^\d{20}$/);
+
+ expect(
+ ibanLib.mod97(ibanLib.toDigitString(bban)),
+ 'the result should be equal to 1'
+ ).toBe(1);
+ });
+
+ it('IBAN for Albania is correct', () => {
+ // Albania
+ // https://wise.com/gb/iban/albania
+ //
+ // example Albania IBAN: AL64 0650 0752 4840 3787 O431 31W3
+ // Length 28
+ // BBAN 2c,26n
+ // AL
+ // Check digits 2 digits
+ // Bank code 3 digits
+ // Branch code 4 digits
+ // National check digit 1 digit
+ // Bank account number 16 digit
+
+ const iban = faker.finance.iban(false, 'AL');
+ const ibanFormated = iban.match(/.{1,4}/g).join(' ');
+
+ expect(iban).satisfy(validator.isIBAN);
+
+ expect(
+ 28,
+ `AL IBAN would be 28 chars length, given is ${iban.length}`
+ ).toBe(iban.length);
+
+ expect(
+ 34,
+ `AL formatted IBAN would be 34 chars length, given is ${ibanFormated.length}`
+ ).toBe(ibanFormated.length);
+
+ expect(
+ iban.substring(0, 2),
+ `First two character should be AL, given is ${iban.substring(0, 2)}`
+ ).toBe('AL');
+ });
});
}
});
diff --git a/test/helpers.spec.ts b/test/helpers.spec.ts
index 929678c7f08..9f81e20191f 100644
--- a/test/helpers.spec.ts
+++ b/test/helpers.spec.ts
@@ -1,4 +1,4 @@
-import { afterEach, describe, expect, it } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
import { luhnCheck } from './support/luhnCheck';
@@ -44,7 +44,7 @@ const seededRuns = [
},
],
address: {
- city: 'Leopoldbury',
+ city: 'Leopoldview',
country: 'Aruba',
geo: {
lat: '51.3317',
@@ -63,7 +63,7 @@ const seededRuns = [
name: 'Weissnat, Wintheiser and MacGyver',
},
email: 'Isabel5@gmail.com',
- name: 'Lorene Deckow',
+ name: 'Darnell Deckow',
phone: '559.640.8661',
posts: [
{
@@ -123,7 +123,7 @@ const seededRuns = [
},
userCard: {
address: {
- city: 'North Wainochester',
+ city: 'North Wainomouth',
geo: {
lat: '4.4562',
lng: '-177.4562',
@@ -138,7 +138,7 @@ const seededRuns = [
name: 'Langworth - Wyman',
},
email: 'Isabel5@gmail.com',
- name: 'Lorene Deckow',
+ name: 'Darnell Deckow',
phone: '225-631-0293 x240',
username: 'Moses_Satterfield',
website: 'sparse-ottoman.biz',
@@ -213,7 +213,7 @@ const seededRuns = [
name: 'Armstrong, Smitham and Renner',
},
email: 'Darron.Larson@gmail.com',
- name: 'Marilyn Effertz',
+ name: 'Eugene Effertz',
phone: '818-698-6199 x848',
posts: [
{
@@ -287,7 +287,7 @@ const seededRuns = [
name: 'Daugherty - Connelly',
},
email: 'Darron.Larson@gmail.com',
- name: 'Marilyn Effertz',
+ name: 'Eugene Effertz',
phone: '803.543.5573 x1428',
username: 'Dudley.Littel',
website: 'queasy-guide.info',
@@ -362,7 +362,7 @@ const seededRuns = [
name: 'Jacobi and Sons',
},
email: 'Marlen.Effertz35@gmail.com',
- name: 'Darrel Sanford',
+ name: 'Henrietta Sanford',
phone: '621-735-9398',
posts: [
{
@@ -396,7 +396,7 @@ const seededRuns = [
},
contextualCard: {
address: {
- city: 'Susieville',
+ city: 'Susieberg',
geo: {
lat: '-88.0651',
lng: '-37.2858',
@@ -421,7 +421,7 @@ const seededRuns = [
},
userCard: {
address: {
- city: 'Reingerfort',
+ city: 'Reingerfield',
geo: {
lat: '73.0714',
lng: '-108.2073',
@@ -436,7 +436,7 @@ const seededRuns = [
name: 'Fahey LLC',
},
email: 'Marlen.Effertz35@gmail.com',
- name: 'Darrel Sanford',
+ name: 'Henrietta Sanford',
phone: '469.570.3390',
username: 'Dangelo.Christiansen67',
website: 'mild-hearth.org',
@@ -724,11 +724,50 @@ describe('helpers', () => {
});
describe('mustache()', () => {
- it('returns empty string with no arguments', () => {
- expect(
- // @ts-expect-error
- faker.helpers.mustache()
- ).toBe('');
+ it('returns empty string with no template input', () => {
+ expect(faker.helpers.mustache(undefined, {})).toBe('');
+ });
+
+ it('returns empty string with empty template input', () => {
+ expect(faker.helpers.mustache('', {})).toBe('');
+ });
+
+ it('supports string replace values', () => {
+ const actual = faker.helpers.mustache('1{{value}}3', { value: '2' });
+
+ expect(actual).toBe('123');
+ });
+
+ it('supports function replace values faker values', () => {
+ const actual = faker.helpers.mustache('1{{value}}3', {
+ value: faker.datatype.string(2),
+ });
+
+ expect(actual).toHaveLength(4);
+ });
+
+ it('supports function replace values faker function', () => {
+ const actual = faker.helpers.mustache('1{{value}}3', {
+ value: () => faker.datatype.string(3),
+ });
+
+ expect(actual).toHaveLength(5);
+ });
+
+ it('supports function replace values no args', () => {
+ const actual = faker.helpers.mustache('1{{value}}3', {
+ value: () => '7',
+ });
+
+ expect(actual).toBe('173');
+ });
+
+ it('supports function replace values with args', () => {
+ const actual = faker.helpers.mustache('1{{value}}3', {
+ value: (key) => String(key.length),
+ });
+
+ expect(actual).toBe('193');
});
});
@@ -764,6 +803,37 @@ describe('helpers', () => {
expect(transaction.account).toBeTruthy();
});
});
+
+ describe('deprecation warnings', () => {
+ it.each([['randomize', 'random.arrayElement']])(
+ 'should warn user that function helpers.%s is deprecated',
+ (functionName, newLocation) => {
+ const spy = vi.spyOn(console, 'warn');
+
+ faker.helpers[functionName]();
+
+ expect(spy).toHaveBeenCalledWith(
+ `[@faker-js/faker]: faker.helpers.${functionName}() is deprecated and will be removed in v7.0.0. Please use faker.${newLocation}() instead.`
+ );
+ spy.mockRestore();
+ }
+ );
+ });
}
});
+ describe('deprecation warnings', () => {
+ it.each(['createCard', 'contextualCard', 'userCard'])(
+ 'should warn user that function random.%s is deprecated',
+ (functionName) => {
+ const spy = vi.spyOn(console, 'warn');
+
+ faker.helpers[functionName]();
+
+ expect(spy).toHaveBeenCalledWith(
+ `[@faker-js/faker]: helpers.${functionName}() is deprecated since v6.1.0 and will be removed in v7.0.0. Please use a self-build function instead.`
+ );
+ spy.mockRestore();
+ }
+ );
+ });
});
diff --git a/test/lorem.spec.ts b/test/lorem.spec.ts
index 2ceb670f3b6..1f2dbc5b22f 100644
--- a/test/lorem.spec.ts
+++ b/test/lorem.spec.ts
@@ -19,7 +19,7 @@ const seededRuns = [
'Hic sit minus dolor animi mollitia sequi ducimus sequi. Inventore praesentium et. Animi qui impedit et voluptatem. Ut quisquam fugiat.',
'Alias sit asperiores sit. Corporis laborum cupiditate consequatur et voluptatem nostrum. Laborum in eos quae nostrum aut consequatur. Blanditiis sunt repellendus et. Eum sint voluptatibus deserunt. Quae eos est soluta ipsum qui.',
'Hic earum delectus. Consequatur eum corporis perferendis aspernatur incidunt nobis. Odio nobis quia est.',
- ].join('\n \r'),
+ ].join('\n'),
text: 'Hic sit minus dolor animi mollitia sequi ducimus sequi.',
lines: [
'Hic sit minus dolor animi mollitia sequi ducimus sequi.',
@@ -42,7 +42,7 @@ const seededRuns = [
'Nesciunt non minima perspiciatis praesentium aperiam voluptatem. Occaecati deserunt voluptatem suscipit. Enim minus nemo fugit et iure explicabo et commodi consequuntur. Voluptatibus nesciunt dignissimos eos temporibus temporibus autem consequatur.',
'Esse vel qui occaecati omnis quis. Voluptatum quis et libero. Et odio dolor qui velit qui. Eveniet provident non fugiat.',
'A a aut nihil. Quas eligendi excepturi eligendi perferendis quo minus et asperiores. Neque blanditiis consequuntur esse autem harum eligendi aut. Cum consequatur pariatur. Omnis temporibus sapiente.',
- ].join('\n \r'),
+ ].join('\n'),
text: 'natus nesciunt non',
lines: [
'Nesciunt non minima perspiciatis praesentium aperiam voluptatem.',
@@ -66,7 +66,7 @@ const seededRuns = [
'Saepe omnis tempora magni repellat eaque. Nesciunt nobis non voluptas quam ex neque eligendi. Vel perferendis assumenda nam expedita est eum molestiae. Ullam et maiores vero doloribus eius. Officia et velit voluptatem quis dolorum. Dignissimos voluptas aut qui corporis itaque sit provident quam aut.',
'In ullam quia impedit. Occaecati repudiandae ut maiores pariatur enim. Deserunt voluptatem in enim in quia.',
'Ut eligendi tempora eos ipsa cumque nulla. Quidem et sed voluptate et quia. Nulla esse in similique deleniti beatae eaque.',
- ].join('\n \r'),
+ ].join('\n'),
text: [
'Omnis tempora magni repellat eaque tempore nesciunt nobis non voluptas.',
'Ex neque eligendi placeat vel perferendis.',
@@ -320,7 +320,7 @@ describe('lorem', () => {
expect(actual).toBeTypeOf('string');
expect(actual[actual.length - 1]).toBe('.');
- const paragraphs = actual.split('\n \r');
+ const paragraphs = actual.split('\n');
expect(paragraphs).toHaveLength(paragraphCount);
});
diff --git a/test/mersenne.spec.ts b/test/mersenne.spec.ts
index b2201240f03..642731b2488 100644
--- a/test/mersenne.spec.ts
+++ b/test/mersenne.spec.ts
@@ -1,4 +1,5 @@
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
+import { FakerError } from '../src/errors/faker-error';
import { Mersenne } from '../src/mersenne';
type SeededRun = {
@@ -8,7 +9,7 @@ type SeededRun = {
type SeededRunExpectations = {
rand: {
noArgs: number;
- minMax: { max?: number; min?: number; expected?: number; skip?: boolean }[];
+ minMax: { max?: number; min?: number; expected?: number }[];
};
};
@@ -21,7 +22,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 37 },
{ max: undefined, min: 0, expected: 12272 },
- { max: 100, min: undefined, expected: 37, skip: true },
+ { max: 100, min: undefined, expected: 37 },
],
},
},
@@ -34,7 +35,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 26 },
{ max: undefined, min: 0, expected: 8586 },
- { max: 100, min: undefined, expected: 26, skip: true },
+ { max: 100, min: undefined, expected: 26 },
],
},
},
@@ -47,7 +48,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 92 },
{ max: undefined, min: 0, expected: 30425 },
- { max: 100, min: undefined, expected: 92, skip: true },
+ { max: 100, min: undefined, expected: 92 },
],
},
},
@@ -60,7 +61,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 85 },
{ max: undefined, min: 0, expected: 28056 },
- { max: 100, min: undefined, expected: 85, skip: true },
+ { max: 100, min: undefined, expected: 85 },
],
},
},
@@ -73,7 +74,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 17 },
{ max: undefined, min: 0, expected: 5895 },
- { max: 100, min: undefined, expected: 17, skip: true },
+ { max: 100, min: undefined, expected: 17 },
],
},
},
@@ -86,7 +87,7 @@ const seededRuns: SeededRun[] = [
minMax: [
{ max: 100, min: 0, expected: 89 },
{ max: undefined, min: 0, expected: 29217 },
- { max: 100, min: undefined, expected: 89, skip: true },
+ { max: 100, min: undefined, expected: 89 },
],
},
},
@@ -122,9 +123,7 @@ describe('mersenne twister', () => {
});
}
- for (const { min, max, expected } of expectations.rand.minMax.filter(
- (x) => !x.skip
- )) {
+ for (const { min, max, expected } of expectations.rand.minMax) {
it(`should return ${expected} for rand(${max}, ${min})`, () => {
const actual = mersenne.rand(max, min);
@@ -132,18 +131,6 @@ describe('mersenne twister', () => {
});
}
- // TODO @piotrekn 2022-02-13: There is a bug: https://github.com/faker-js/faker/issues/479
- // remove minMax.skip when fixed
- for (const { min, max, expected } of expectations.rand.minMax.filter(
- (x) => x.skip
- )) {
- it.todo(`should return ${expected} for rand(${max}, ${min})`, () => {
- const actual = mersenne.rand(max, min);
-
- expect(actual).toEqual(expected);
- });
- }
-
it.todo(`should return 0 for rand(1)`, () => {
const actual = mersenne.rand(1);
@@ -195,7 +182,9 @@ describe('mersenne twister', () => {
// @ts-expect-error: non-integer error
'abc'
)
- ).toThrowError(Error('seed(S) must take numeric argument; is string'));
+ ).toThrowError(
+ new FakerError('seed(S) must take numeric argument; is string')
+ );
});
it('should throw an error when attempting to seed() a non-integer', () => {
@@ -205,7 +194,7 @@ describe('mersenne twister', () => {
'abc'
)
).toThrowError(
- Error('seed_array(A) must take array of numbers; is string')
+ new FakerError('seed_array(A) must take array of numbers; is string')
);
});
});
diff --git a/test/name.spec.ts b/test/name.spec.ts
index a8c0c986032..97ac7fbacb3 100644
--- a/test/name.spec.ts
+++ b/test/name.spec.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
const seededRuns = [
@@ -12,10 +12,10 @@ const seededRuns = [
noArgs: 'Hintz',
},
middleName: {
- noArgs: 'b',
+ noArgs: 'Greer',
},
findName: {
- noArgs: 'Lorene Deckow',
+ noArgs: 'Darnell Deckow',
},
jobTitle: {
noArgs: 'Regional Data Representative',
@@ -53,10 +53,10 @@ const seededRuns = [
noArgs: 'Gibson',
},
middleName: {
- noArgs: 'a',
+ noArgs: 'Dakota',
},
findName: {
- noArgs: 'Marilyn Effertz',
+ noArgs: 'Eugene Effertz',
},
jobTitle: {
noArgs: 'Future Infrastructure Liaison',
@@ -94,10 +94,10 @@ const seededRuns = [
noArgs: 'Ward',
},
middleName: {
- noArgs: 'c',
+ noArgs: 'Sawyer',
},
findName: {
- noArgs: 'Darrel Sanford',
+ noArgs: 'Henrietta Sanford',
},
jobTitle: {
noArgs: 'Chief Division Agent',
@@ -147,6 +147,7 @@ const functionNames = [
describe('name', () => {
afterEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
for (const { seed, expectations } of seededRuns) {
@@ -172,6 +173,7 @@ describe('name', () => {
describe('firstName()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a random first name', () => {
@@ -182,27 +184,47 @@ describe('name', () => {
});
it('should return a gender-specific first name when passed a number', () => {
+ const spy = vi.spyOn(console, 'warn');
+
let name = faker.name.firstName(0);
expect(faker.definitions.name.male_first_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.firstName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
name = faker.name.firstName(1);
expect(faker.definitions.name.female_first_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.firstName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
+ spy.mockRestore();
});
- // TODO @Shinigami92 2022-01-30: There is a bug: https://github.com/faker-js/faker/issues/373
- it.todo(
- 'should return a gender-specific first name when passed a string',
- () => {
- let name = faker.name.firstName('male');
- expect(faker.definitions.name.male_first_name).toContain(name);
- name = faker.name.firstName('female');
- expect(faker.definitions.name.female_first_name).toContain(name);
- }
- );
+ it('should return a gender-specific first name when passed a string', () => {
+ let name = faker.name.firstName('female');
+ expect(faker.definitions.name.female_first_name).toContain(name);
+
+ name = faker.name.firstName('male');
+ expect(faker.definitions.name.male_first_name).toContain(name);
+ });
+
+ it('should return a gender-specific first name when no gender-specific first name was defined', () => {
+ faker.locale = 'az';
+ faker.localeFallback = 'az';
+
+ const name = faker.name.firstName();
+ expect([
+ ...faker.definitions.name.female_first_name,
+ ...faker.definitions.name.male_first_name,
+ ]).toContain(name);
+ });
});
describe('lastName()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a random last name', () => {
@@ -215,29 +237,38 @@ describe('name', () => {
it('should return a gender-specific last name when passed a number', () => {
faker.locale = 'az';
+ const spy = vi.spyOn(console, 'warn');
+
let name = faker.name.lastName(0);
expect(faker.definitions.name.male_last_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.lastName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
name = faker.name.lastName(1);
expect(faker.definitions.name.female_last_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.lastName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
+ spy.mockRestore();
});
- // TODO @Shinigami92 2022-01-30: There is a bug: https://github.com/faker-js/faker/issues/373
- it.todo(
- 'should return a gender-specific last name when passed a string',
- () => {
- faker.locale = 'az';
+ it('should return a gender-specific last name when passed a string', () => {
+ faker.locale = 'az';
- let name = faker.name.lastName('male');
- expect(faker.definitions.name.male_last_name).toContain(name);
- name = faker.name.lastName('female');
- expect(faker.definitions.name.female_last_name).toContain(name);
- }
- );
+ let name = faker.name.lastName('female');
+ expect(faker.definitions.name.female_last_name).toContain(name);
+
+ name = faker.name.lastName('male');
+ expect(faker.definitions.name.male_last_name).toContain(name);
+ });
});
describe('middleName()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a random middle name', () => {
@@ -247,32 +278,54 @@ describe('name', () => {
expect(middle_name.length).greaterThan(0);
});
+ it('should return a middle name when passed en locale', () => {
+ faker.locale = 'en';
+
+ let name = faker.name.middleName();
+ expect(faker.definitions.name.middle_name).toContain(name);
+
+ name = faker.name.middleName('female');
+ expect(faker.definitions.name.female_middle_name).toContain(name);
+
+ name = faker.name.middleName('male');
+ expect(faker.definitions.name.male_middle_name).toContain(name);
+ });
+
it('should return a gender-specific middle name when passed a number', () => {
+ const spy = vi.spyOn(console, 'warn');
+
faker.locale = 'uk';
let name = faker.name.middleName(0);
expect(faker.definitions.name.male_middle_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.middleName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
name = faker.name.middleName(1);
expect(faker.definitions.name.female_middle_name).toContain(name);
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.middleName(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
+ spy.mockRestore();
});
- // TODO @Shinigami92 2022-01-30: There is a bug: https://github.com/faker-js/faker/issues/373
- it.todo(
- 'should return a gender-specific middle name when passed a string',
- () => {
- faker.locale = 'uk';
+ it('should return a gender-specific middle name when passed a string', () => {
+ faker.locale = 'uk';
- let name = faker.name.middleName('male');
- expect(faker.definitions.name.male_middle_name).toContain(name);
- name = faker.name.middleName('female');
- expect(faker.definitions.name.female_middle_name).toContain(name);
- }
- );
+ let name = faker.name.middleName('female');
+ expect(faker.definitions.name.female_middle_name).toContain(name);
+
+ name = faker.name.middleName('male');
+ expect(faker.definitions.name.male_middle_name).toContain(name);
+ });
});
describe('findName()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a name with firstName and lastName', () => {
@@ -282,24 +335,6 @@ describe('name', () => {
expect(fullName).toContain(' ');
});
- it('should return a male gender-specific name with firstName and lastName', () => {
- faker.locale = 'mk';
-
- const male_specific = [
- ...faker.definitions.name.male_prefix,
- ...faker.definitions.name.male_first_name,
- ...faker.definitions.name.male_last_name,
- ...faker.definitions.name.suffix,
- ];
-
- const fullName = faker.name.findName(undefined, undefined, 0);
-
- const parts = fullName.split(' ');
- for (const part of parts) {
- expect(male_specific).toContain(part);
- }
- });
-
it('should return a female gender-specific name with firstName and lastName', () => {
faker.locale = 'mk';
@@ -310,7 +345,7 @@ describe('name', () => {
...faker.definitions.name.suffix,
];
- const fullName = faker.name.findName(undefined, undefined, 1);
+ const fullName = faker.name.findName(undefined, undefined, 'female');
const parts = fullName.split(' ');
for (const part of parts) {
@@ -318,17 +353,17 @@ describe('name', () => {
}
});
- it('should return a male gender-specific name with given firstName and lastName', () => {
+ it('should return a male gender-specific name with firstName and lastName', () => {
faker.locale = 'mk';
const male_specific = [
...faker.definitions.name.male_prefix,
- 'firstName',
- 'lastName',
+ ...faker.definitions.name.male_first_name,
+ ...faker.definitions.name.male_last_name,
...faker.definitions.name.suffix,
];
- const fullName = faker.name.findName('firstName', 'lastName', 0);
+ const fullName = faker.name.findName(undefined, undefined, 'male');
const parts = fullName.split(' ');
for (const part of parts) {
@@ -346,36 +381,41 @@ describe('name', () => {
...faker.definitions.name.suffix,
];
- const fullName = faker.name.findName('firstName', 'lastName', 1);
+ const fullName = faker.name.findName(
+ 'firstName',
+ 'lastName',
+ 'female'
+ );
const parts = fullName.split(' ');
for (const part of parts) {
expect(male_specific).toContain(part);
}
});
- });
-
- describe('jobTitle()', () => {
- beforeEach(() => {
- faker.locale = 'en';
- });
- it('should return a job title consisting of a descriptor, area, and type', () => {
- const jobTitle = faker.name.jobTitle();
+ it('should return a male gender-specific name with given firstName and lastName', () => {
+ faker.locale = 'mk';
- expect(jobTitle).toBeTypeOf('string');
+ const male_specific = [
+ ...faker.definitions.name.male_prefix,
+ 'firstName',
+ 'lastName',
+ ...faker.definitions.name.suffix,
+ ];
- const [descriptor, level, job] = jobTitle.split(' ');
+ const fullName = faker.name.findName('firstName', 'lastName', 'male');
- expect(faker.definitions.name.title.descriptor).toContain(descriptor);
- expect(faker.definitions.name.title.level).toContain(level);
- expect(faker.definitions.name.title.job).toContain(job);
+ const parts = fullName.split(' ');
+ for (const part of parts) {
+ expect(male_specific).toContain(part);
+ }
});
});
describe('gender()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a default gender', () => {
@@ -396,6 +436,7 @@ describe('name', () => {
describe('prefix()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a prefix', () => {
@@ -405,17 +446,16 @@ describe('name', () => {
expect(faker.definitions.name.prefix).toContain(prefix);
});
- it('should return a male prefix', () => {
+ it('should return a female prefix with given string', () => {
faker.locale = 'mk';
- const prefix = faker.name.prefix(0);
+ const prefix = faker.name.prefix('female');
expect(prefix).toBeTypeOf('string');
- expect(faker.definitions.name.male_prefix).toContain(prefix);
+ expect(faker.definitions.name.female_prefix).toContain(prefix);
});
- // TODO @Shinigami92 2022-01-31: There is a bug: https://github.com/faker-js/faker/issues/373
- it.todo('should return a male prefix with given string', () => {
+ it('should return a male prefix with given string', () => {
faker.locale = 'mk';
const prefix = faker.name.prefix('male');
@@ -424,29 +464,45 @@ describe('name', () => {
expect(faker.definitions.name.male_prefix).toContain(prefix);
});
- it('should return a female prefix', () => {
+ it('should return a male prefix with given number', () => {
+ const spy = vi.spyOn(console, 'warn');
+
faker.locale = 'mk';
- const prefix = faker.name.prefix(1);
+ const prefix = faker.name.prefix(0);
expect(prefix).toBeTypeOf('string');
- expect(faker.definitions.name.female_prefix).toContain(prefix);
+ expect(faker.definitions.name.male_prefix).toContain(prefix);
+
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.prefix(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
+ spy.mockRestore();
});
- // TODO @Shinigami92 2022-01-31: There is a bug: https://github.com/faker-js/faker/issues/373
- it.todo('should return a female prefix with given string', () => {
+ it('should return a female prefix with given number', () => {
+ const spy = vi.spyOn(console, 'warn');
+
faker.locale = 'mk';
- const prefix = faker.name.prefix('female');
+ const prefix = faker.name.prefix(1);
expect(prefix).toBeTypeOf('string');
expect(faker.definitions.name.female_prefix).toContain(prefix);
+
+ expect(spy).toHaveBeenCalledWith(
+ "[@faker-js/faker]: name.prefix(number) is deprecated since v6.1.0 and will be removed in v7.0.0. Please use 'female' or 'male' instead."
+ );
+
+ spy.mockRestore();
});
});
describe('suffix()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a suffix', () => {
@@ -460,6 +516,29 @@ describe('name', () => {
describe('title()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
+ });
+
+ it('should display deprecated message', () => {
+ const spy = vi.spyOn(console, 'warn');
+
+ faker.name.title();
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.name.title() is deprecated since v6.1.2 and will be removed in v7.0.0. Please use faker.name.jobTitle() instead.'
+ );
+
+ spy.mockRestore();
+ });
+
+ it('should call jobTitle()', () => {
+ const spy = vi.spyOn(faker.name, 'jobTitle');
+
+ faker.name.title();
+
+ expect(spy).toHaveBeenCalledWith();
+
+ spy.mockRestore();
});
it('should return a title consisting of a descriptor, area, and type', () => {
@@ -469,7 +548,25 @@ describe('name', () => {
const [descriptor, level, job] = title.split(' ');
- // TODO @Shinigami92 2022-01-31: jobTitle and title are the same
+ expect(faker.definitions.name.title.descriptor).toContain(descriptor);
+ expect(faker.definitions.name.title.level).toContain(level);
+ expect(faker.definitions.name.title.job).toContain(job);
+ });
+ });
+
+ describe('jobTitle()', () => {
+ beforeEach(() => {
+ faker.locale = 'en';
+ faker.localeFallback = 'en';
+ });
+
+ it('should return a job title consisting of a descriptor, area, and type', () => {
+ const jobTitle = faker.name.jobTitle();
+
+ expect(jobTitle).toBeTypeOf('string');
+
+ const [descriptor, level, job] = jobTitle.split(' ');
+
expect(faker.definitions.name.title.descriptor).toContain(descriptor);
expect(faker.definitions.name.title.level).toContain(level);
expect(faker.definitions.name.title.job).toContain(job);
@@ -479,6 +576,7 @@ describe('name', () => {
describe('jobDescriptor()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a descriptor', () => {
@@ -493,6 +591,7 @@ describe('name', () => {
describe('jobArea()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a level', () => {
@@ -507,6 +606,7 @@ describe('name', () => {
describe('jobType()', () => {
beforeEach(() => {
faker.locale = 'en';
+ faker.localeFallback = 'en';
});
it('should return a job', () => {
diff --git a/test/random.spec.ts b/test/random.spec.ts
index 07b2a0f5b6b..79dbf18d5ef 100644
--- a/test/random.spec.ts
+++ b/test/random.spec.ts
@@ -1,5 +1,6 @@
-import { describe, expect, it, vi } from 'vitest';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
+import { times } from './support/times';
describe('random', () => {
describe('arrayElement', () => {
@@ -78,15 +79,72 @@ describe('random', () => {
});
describe('word', () => {
+ const bannedChars = [
+ '!',
+ '#',
+ '%',
+ '&',
+ '*',
+ ')',
+ '(',
+ '+',
+ '=',
+ '.',
+ '<',
+ '>',
+ '{',
+ '}',
+ '[',
+ ']',
+ ':',
+ ';',
+ "'",
+ '"',
+ '_',
+ '-',
+ ];
+
+ beforeEach(() => {
+ faker.locale = 'en';
+ });
+
it('should return a random word', () => {
const actual = faker.random.word();
expect(actual).toBeTruthy();
expect(actual).toBeTypeOf('string');
});
+
+ it.each(times(50))(
+ 'should only contain a word without undesirable non-alpha characters (run %i)',
+ () => {
+ const actual = faker.random.word();
+
+ expect(actual).not.satisfy((word: string) =>
+ bannedChars.some((char) => word.includes(char))
+ );
+ }
+ );
+
+ it.each(times(50))(
+ 'should only contain a word without undesirable non-alpha characters, locale=zh_CN (run %i)',
+ () => {
+ faker.locale = 'zh_CN';
+
+ const actual = faker.random.word();
+
+ expect(actual).not.satisfy((word: string) =>
+ bannedChars.some((char) => word.includes(char))
+ );
+ }
+ );
});
describe('words', () => {
+ beforeEach(() => {
+ faker.locale = 'en';
+ });
+
it('should return random words', () => {
const actual = faker.random.words();
@@ -129,12 +187,12 @@ describe('random', () => {
it('should return lowercase letter when no upcase option provided', () => {
const actual = faker.random.alpha();
- expect(actual).match(/[a-z]/);
+ expect(actual).match(/^[a-z]$/);
});
it('should return uppercase when upcase option is true', () => {
const actual = faker.random.alpha({ upcase: true });
- expect(actual).match(/[A-Z]/);
+ expect(actual).match(/^[A-Z]$/);
});
it('should generate many random letters', () => {
@@ -150,7 +208,7 @@ describe('random', () => {
});
expect(actual).toHaveLength(5);
- expect(actual).match(/[b-oq-z]/);
+ expect(actual).match(/^[b-oq-z]{5}$/);
});
it('should be able handle mistake in banned characters array', () => {
@@ -160,7 +218,7 @@ describe('random', () => {
});
expect(alphaText).toHaveLength(5);
- expect(alphaText).match(/[b-oq-z]/);
+ expect(alphaText).match(/^[b-oq-z]{5}$/);
});
});
@@ -207,10 +265,10 @@ describe('random', () => {
});
expect(alphaText).toHaveLength(5);
- expect(alphaText).match(/[b-oq-z]/);
+ expect(alphaText).match(/^[0-9b-oq-z]{5}$/);
});
- it.todo('should throw if all possible characters being banned', () => {
+ it('should throw if all possible characters being banned', () => {
const bannedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'.split('');
expect(() =>
faker.random.alphaNumeric(5, {
@@ -227,7 +285,7 @@ describe('random', () => {
['uuid', 'datatype.uuid'],
['boolean', 'datatype.boolean'],
['image', 'image.image'],
- ['hexaDecimal', 'datatype.hexaDecimal'],
+ ['hexaDecimal', 'datatype.hexadecimal'],
])(
'should warn user that function random.%s is deprecated',
(functionName, newLocation) => {
@@ -236,7 +294,7 @@ describe('random', () => {
faker.random[functionName]();
expect(spy).toHaveBeenCalledWith(
- `Deprecation Warning: faker.random.${functionName} is now located in faker.${newLocation}`
+ `[@faker-js/faker]: faker.random.${functionName}() is deprecated and will be removed in v7.0.0. Please use faker.${newLocation}() instead.`
);
spy.mockRestore();
}
diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts
index 8f1ada32f4d..b413dd20122 100644
--- a/test/scripts/apidoc/signature.example.ts
+++ b/test/scripts/apidoc/signature.example.ts
@@ -60,8 +60,14 @@ export class SignatureTest {
* @param options.a The number parameter.
* @param options.b The string parameter.
* @param options.c The boolean parameter.
+ * @param options.d The method parameter.
*/
- optionsParamMethod(options: { a: number; b?: string; c: boolean }): number {
+ optionsParamMethod(options: {
+ a: number;
+ b?: string;
+ c: boolean;
+ d: () => string;
+ }): number {
return options.c ? options.a : +options.b;
}
diff --git a/test/scripts/apidoc/signature.expected.json b/test/scripts/apidoc/signature.expected.json
index d0674899053..da7c2e87bda 100644
--- a/test/scripts/apidoc/signature.expected.json
+++ b/test/scripts/apidoc/signature.expected.json
@@ -33,12 +33,12 @@
"parameters": [
{
"name": "fn",
- "type": "Function",
+ "type": "(a: string) => number",
"description": "The function parameter.
\n"
}
],
"returns": "number",
- "examples": "faker.functionParamMethod(fn: Function): number\n
\n
",
+ "examples": "faker.functionParamMethod(fn: (a: string) => number): number\n
\n
",
"deprecated": false,
"seeAlsos": []
},
@@ -112,7 +112,7 @@
"parameters": [
{
"name": "options",
- "type": "Object",
+ "type": "{ ... }",
"description": "The function parameter.
\n"
},
{
@@ -129,10 +129,15 @@
"name": "options.c",
"type": "boolean",
"description": "The boolean parameter.
\n"
+ },
+ {
+ "name": "options.d",
+ "type": "() => string",
+ "description": "The method parameter.
\n"
}
],
"returns": "number",
- "examples": "faker.optionsParamMethod(options: Object): number\n
\n
",
+ "examples": "faker.optionsParamMethod(options: {\n a: number,\n b: string,\n c: boolean,\n d: () => string\n}): number\n
\n
",
"deprecated": false,
"seeAlsos": []
},
diff --git a/test/system.spec.ts b/test/system.spec.ts
index 7c6e77609f3..26b5730fbdb 100644
--- a/test/system.spec.ts
+++ b/test/system.spec.ts
@@ -2,53 +2,49 @@ import validator from 'validator';
import { afterEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
-// TODO @prisis 2022-01-31: Add multiple seed based expectations.
const seededRuns = [
{
seed: 42,
expectations: {
- fileName: 'mobile_application.wad',
- commonFileName: 'mobile_application.gif',
+ fileName: 'mobile_fish.gif',
+ commonFileName: 'mobile_fish.mpe',
mimeType: 'application/vnd.marlin.drm.license+xml',
commonFileType: 'audio',
commonFileExt: 'png',
fileType: 'image',
fileExt: 'chm',
directoryPath: '/opt/bin',
- // TODO @prisis 2022-01-25: add a parameter to have the possibility to have one or two ext on file.
- filePath: '/opt/bin/directives_multi_byte_table.p10.m21',
+ filePath: '/opt/bin/directives_application_home.paw',
semver: '3.7.9',
},
},
{
seed: 1337,
expectations: {
- fileName: 'delaware.vcg',
- commonFileName: 'delaware.wav',
+ fileName: 'delaware.uvvt',
+ commonFileName: 'delaware.mp2',
mimeType: 'application/vnd.dxr',
commonFileType: 'audio',
commonFileExt: 'wav',
fileType: 'font',
fileExt: 'gxt',
directoryPath: '/Library',
- // TODO @prisis 2022-01-25: add a parameter to have the possibility to have one or two ext on file.
- filePath: '/Library/bike_kiribati.kpr.ez3',
+ filePath: '/Library/bike_interactive.qwt',
semver: '2.5.1',
},
},
{
seed: 1211,
expectations: {
- fileName: 'turnpike_cross_platform_handcrafted.mka',
- commonFileName: 'turnpike_cross_platform_handcrafted.mp4v',
+ fileName: 'turnpike_frozen_handcrafted.mka',
+ commonFileName: 'turnpike_frozen_handcrafted.mp4v',
mimeType: 'text/vnd.fmi.flexstor',
commonFileType: 'application',
commonFileExt: 'htm',
fileType: 'x-shader',
fileExt: 'opml',
directoryPath: '/var/log',
- // TODO @prisis 2022-01-25: add a parameter to have the possibility to have one or two ext on file.
- filePath: '/var/log/forward_frozen.swf.fcdt',
+ filePath: '/var/log/forward_supervisor.swf',
semver: '9.4.8',
},
},
@@ -98,24 +94,28 @@ describe('system', () => {
it('should return common file types', () => {
const fileExt = faker.system.commonFileExt();
const extList = [
- 'pdf',
- 'mpeg',
- 'wav',
- 'png',
- 'jpeg',
'gif',
- 'mp4v',
- 'mpeg',
'htm',
+ 'html',
+ 'jpeg',
'm2a',
+ 'm2v',
+ 'mp2',
+ 'mp3',
'mp4',
+ 'mp4v',
+ 'mpeg',
'mpg',
+ 'pdf',
+ 'png',
+ 'shtml',
+ 'wav',
];
expect(
extList,
`generated common file ext should be one of [${extList.join(
- ','
+ ', '
)}]. Got "${fileExt}".`
).include(fileExt);
});
@@ -234,12 +234,16 @@ describe('system', () => {
describe('filePath()', () => {
it('should return unix fs file full path', () => {
const filePath = faker.system.filePath();
+ const parts = filePath.split('/');
expect(
filePath.startsWith('/'),
'generated filePath should start with /'
).toBeTruthy();
- // TODO @prisis 2022-01-26: Add test to validate if the path has ext on the end.
+ expect(
+ parts[parts.length - 1],
+ 'generated filePath should have a file extension'
+ ).toMatch(/^\w+\.\w+$/);
});
});
@@ -264,4 +268,19 @@ describe('system', () => {
});
}
});
+
+ describe('extra tests', () => {
+ describe('commonFileName()', () => {
+ afterEach(() => {
+ faker.locale = 'en';
+ });
+
+ it('#770', () => {
+ faker.seed(5423027051750305);
+ faker.setLocale('sk');
+ faker.system.commonFileName('xml');
+ faker.system.commonFileName('xml');
+ });
+ });
+ });
});
diff --git a/test/time.spec.ts b/test/time.spec.ts
index 1146bb083cf..82c3fbae3af 100644
--- a/test/time.spec.ts
+++ b/test/time.spec.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
const seededRuns = [
@@ -56,23 +56,51 @@ describe('time', () => {
for (let i = 1; i <= NON_SEEDED_BASED_RUN; i++) {
describe('recent()', () => {
it('should return the recent timestamp in unix time format by default', () => {
+ const spy = vi.spyOn(console, 'warn');
+
const date = faker.time.recent();
expect(date).toBeTypeOf('number');
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.time.recent() is deprecated since v6.1.0 and will be removed in v7.0.0. Please use native `new Date()` and call the function you want on it instead.'
+ );
+ spy.mockRestore();
});
it('should return the recent timestamp in full time string format', () => {
+ const spy = vi.spyOn(console, 'warn');
+
const date = faker.time.recent('wide');
expect(date).toBeTypeOf('string');
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.time.recent() is deprecated since v6.1.0 and will be removed in v7.0.0. Please use native `new Date()` and call the function you want on it instead.'
+ );
+ spy.mockRestore();
});
it('should return the recent timestamp in abbreviated string format', () => {
+ const spy = vi.spyOn(console, 'warn');
+
const date = faker.time.recent('abbr');
expect(date).toBeTypeOf('string');
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.time.recent() is deprecated since v6.1.0 and will be removed in v7.0.0. Please use native `new Date()` and call the function you want on it instead.'
+ );
+ spy.mockRestore();
});
it('should return the recent timestamp in unix time format', () => {
+ const spy = vi.spyOn(console, 'warn');
+
const date = faker.time.recent('unix');
expect(date).toBeTypeOf('number');
+
+ expect(spy).toHaveBeenCalledWith(
+ '[@faker-js/faker]: faker.time.recent() is deprecated since v6.1.0 and will be removed in v7.0.0. Please use native `new Date()` and call the function you want on it instead.'
+ );
+ spy.mockRestore();
});
});
}
diff --git a/test/unique.spec.ts b/test/unique.spec.ts
index 483fe05e599..fab12ba7002 100644
--- a/test/unique.spec.ts
+++ b/test/unique.spec.ts
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
+import { FakerError } from '../src/errors/faker-error';
const seededRuns = [
{
@@ -120,6 +121,16 @@ describe('unique', () => {
});
}).toThrowError(/^Exceeded maxRetries:/);
});
+
+ it('should throw a FakerError instance on error', () => {
+ expect(() => {
+ faker.unique(faker.internet.protocol, [], {
+ maxTime: 5000,
+ maxRetries: 5,
+ exclude: ['https', 'http'],
+ });
+ }).toThrowError(FakerError);
+ });
});
}
});
@@ -133,4 +144,21 @@ describe('unique', () => {
});
expect(result).toBe('http');
});
+
+ it('no conflict', () => {
+ let i = 0;
+ const method = () => `no conflict: ${i++}`;
+ expect(faker.unique(method)).toBe('no conflict: 0');
+ expect(faker.unique(method)).toBe('no conflict: 1');
+ });
+
+ it('with conflict', () => {
+ const method = () => 'with conflict: 0';
+ expect(faker.unique(method)).toBe('with conflict: 0');
+ expect(() =>
+ faker.unique(method, [], {
+ maxRetries: 1,
+ })
+ ).toThrow();
+ });
});
diff --git a/test/vehicle.spec.ts b/test/vehicle.spec.ts
index b52ccff6b74..28757e6b03a 100644
--- a/test/vehicle.spec.ts
+++ b/test/vehicle.spec.ts
@@ -24,7 +24,7 @@ const seededRuns = [
model: 'Colorado',
type: 'Coupe',
fuel: 'Electric',
- vin: '8J579HF1A7MK33575',
+ vin: '8J579HF1A7MK33574',
color: 'black',
vrm: 'GO12HOL',
bicycle: 'Cyclocross Bicycle',
@@ -38,7 +38,7 @@ const seededRuns = [
model: '2',
type: 'Wagon',
fuel: 'Hybrid',
- vin: 'XFWS74Z1N5S678768',
+ vin: 'XFWS74Z1N5S678767',
color: 'azure',
vrm: 'YL87FDZ',
bicycle: 'Triathlon/Time Trial Bicycle',
@@ -107,6 +107,15 @@ describe('vehicle', () => {
});
});
+ describe('vin()', () => {
+ it('returns valid vin number', () => {
+ const vin = faker.vehicle.vin();
+ expect(vin).toMatch(
+ /^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/
+ );
+ });
+ });
+
describe('model()', () => {
it('should return random vehicle model', () => {
const model = faker.vehicle.model();
diff --git a/test/word.spec.ts b/test/word.spec.ts
index ac40c8a5e01..d236f564a0c 100644
--- a/test/word.spec.ts
+++ b/test/word.spec.ts
@@ -8,37 +8,37 @@ const seededRuns = [
adjective: {
noArgs: 'harmonious',
length10: 'gregarious',
- length20: 'stable',
+ length20: 'harmonious',
},
adverb: {
noArgs: 'jealously',
length10: 'generously',
- length20: 'swiftly',
+ length20: 'jealously',
},
conjunction: {
noArgs: 'however',
length10: 'as much as',
- length20: 'since',
+ length20: 'however',
},
interjection: {
noArgs: 'yahoo',
- length10: 'ack',
- length20: 'ack',
+ length10: 'yahoo',
+ length20: 'yahoo',
},
noun: {
noArgs: 'gale',
length10: 'exposition',
- length20: 'shift',
+ length20: 'gale',
},
preposition: {
noArgs: 'concerning',
length10: 'throughout',
- length20: 'than',
+ length20: 'concerning',
},
verb: {
noArgs: 'function',
length10: 'exasperate',
- length20: 'shred',
+ length20: 'function',
},
},
},
@@ -48,37 +48,37 @@ const seededRuns = [
adjective: {
noArgs: 'fabulous',
length10: 'enchanting',
- length20: 'neat',
+ length20: 'fabulous',
},
adverb: {
noArgs: 'frankly',
length10: 'enormously',
- length20: 'overconfidently',
+ length20: 'frankly',
},
conjunction: {
noArgs: 'even if',
length10: 'as long as',
- length20: 'instead',
+ length20: 'even if',
},
interjection: {
noArgs: 'ew',
- length10: 'yippee',
- length20: 'yippee',
+ length10: 'ew',
+ length20: 'ew',
},
noun: {
noArgs: 'digit',
length10: 'depressive',
- length20: 'might',
+ length20: 'digit',
},
preposition: {
noArgs: 'barring',
length10: 'concerning',
- length20: 'midst',
+ length20: 'barring',
},
verb: {
noArgs: 'dispense',
length10: 'demoralize',
- length20: 'nearest',
+ length20: 'dispense',
},
},
},
@@ -88,37 +88,37 @@ const seededRuns = [
adjective: {
noArgs: 'verifiable',
length10: 'unfinished',
- length20: 'joyous',
+ length20: 'verifiable',
},
adverb: {
noArgs: 'viciously',
length10: 'unbearably',
- length20: 'loudly',
+ length20: 'viciously',
},
conjunction: {
noArgs: 'whereas',
length10: 'as soon as',
- length20: 'in addition',
+ length20: 'whereas',
},
interjection: {
noArgs: 'er',
- length10: 'gah',
- length20: 'gah',
+ length10: 'er',
+ length20: 'er',
},
noun: {
noArgs: 'trick',
length10: 'trafficker',
- length20: 'infection',
+ length20: 'trick',
},
preposition: {
noArgs: 'upon',
length10: 'underneath',
- length20: 'for',
+ length20: 'upon',
},
verb: {
noArgs: 'trick',
length10: 'trampoline',
- length20: 'intercede',
+ length20: 'trick',
},
},
},
diff --git a/tsconfig.json b/tsconfig.json
index 9f2fe64c876..06a5489f6a5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,7 +4,16 @@
"outDir": "dist",
"declaration": true,
"esModuleInterop": true,
- "allowJs": true
+ "allowJs": true,
+ "alwaysStrict": true,
+ // "strictNullChecks": true,
+ // "strictBindCallApply": true,
+ "strictFunctionTypes": true,
+ // "strictPropertyInitialization": true,
+ // "noImplicitAny": true,
+ // "noImplicitThis": true,
+ "useUnknownInCatchVariables": true,
+ "stripInternal": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]