diff options
| author | Owen <[email protected]> | 2025-03-06 12:08:47 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-03-06 17:08:47 +0000 |
| commit | ae9aec67b19f779e818be5550a8edc44f20d91d4 (patch) | |
| tree | 5feaada57958f8e52bf791e91fc00c4893b5ff4f /src/modules/finance | |
| parent | 57d39d74429557a9ebbf777a0c0f413e7851d3fc (diff) | |
| download | faker-ae9aec67b19f779e818be5550a8edc44f20d91d4.tar.xz faker-ae9aec67b19f779e818be5550a8edc44f20d91d4.zip | |
feat(finance): add ISO 4217 numerical codes to Currency (#3404)
Diffstat (limited to 'src/modules/finance')
| -rw-r--r-- | src/modules/finance/index.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index dd8ded53..414d07ee 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -27,6 +27,11 @@ export interface Currency { * The symbol for the currency (e.g. `$`). */ symbol: string; + + /** + * The ISO 4217 numeric code for the currency (e.g. `840`). + */ + numericCode: string; } /** @@ -457,14 +462,15 @@ export class FinanceModule extends ModuleBase { } /** - * Returns a random currency object, containing `code`, `name `and `symbol` properties. + * Returns a random currency object, containing `code`, `name`, `symbol`, and `numericCode` properties. * * @see faker.finance.currencyCode(): For generating specifically the currency code. * @see faker.finance.currencyName(): For generating specifically the currency name. * @see faker.finance.currencySymbol(): For generating specifically the currency symbol. + * @see faker.finance.currencyNumericCode(): For generating specifically the currency numeric code. * * @example - * faker.finance.currency() // { code: 'USD', name: 'US Dollar', symbol: '$' } + * faker.finance.currency() // { code: 'USD', name: 'US Dollar', symbol: '$', numericCode: '840' } * * @since 8.0.0 */ @@ -517,6 +523,19 @@ export class FinanceModule extends ModuleBase { } /** + * Returns a random currency numeric code. + * (The ISO 4217 numerical code for a currency (e.g. `US Dollar` -> `840` )) + * + * @example + * faker.finance.currencyNumericCode() // '840' + * + * @since 9.6.0 + */ + currencyNumericCode(): string { + return this.currency().numericCode; + } + + /** * Generates a random Bitcoin address. * * @param options An optional options object. |
