From ae9aec67b19f779e818be5550a8edc44f20d91d4 Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 6 Mar 2025 12:08:47 -0500 Subject: feat(finance): add ISO 4217 numerical codes to Currency (#3404) --- src/modules/finance/index.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/modules') 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 */ @@ -516,6 +522,19 @@ export class FinanceModule extends ModuleBase { return symbol; } + /** + * 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. * -- cgit v1.2.3