aboutsummaryrefslogtreecommitdiff
path: root/src/modules/finance/index.ts
diff options
context:
space:
mode:
authorOwen <[email protected]>2025-03-06 12:08:47 -0500
committerGitHub <[email protected]>2025-03-06 17:08:47 +0000
commitae9aec67b19f779e818be5550a8edc44f20d91d4 (patch)
tree5feaada57958f8e52bf791e91fc00c4893b5ff4f /src/modules/finance/index.ts
parent57d39d74429557a9ebbf777a0c0f413e7851d3fc (diff)
downloadfaker-ae9aec67b19f779e818be5550a8edc44f20d91d4.tar.xz
faker-ae9aec67b19f779e818be5550a8edc44f20d91d4.zip
feat(finance): add ISO 4217 numerical codes to Currency (#3404)
Diffstat (limited to 'src/modules/finance/index.ts')
-rw-r--r--src/modules/finance/index.ts23
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.