diff options
| author | ST-DDT <[email protected]> | 2024-11-12 09:15:03 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-12 09:15:03 +0100 |
| commit | cb4b77c04f4d4a706819a6f34ff8378afec6523e (patch) | |
| tree | 5553bdcf0d965e6aa81bd4ccb5e1218dcfa7ae35 /src/modules | |
| parent | 9abaed1061b5fa9dc9f93822162610105a788296 (diff) | |
| download | faker-cb4b77c04f4d4a706819a6f34ff8378afec6523e.tar.xz faker-cb4b77c04f4d4a706819a6f34ff8378afec6523e.zip | |
refactor(finance): deprecate maskedNumber for removal (#3201)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/finance/index.ts | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index 0e9a6883..656872b7 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -1,4 +1,5 @@ import { FakerError } from '../../errors/faker-error'; +import { deprecated } from '../../internal/deprecated'; import { ModuleBase } from '../../internal/module-base'; import type { BitcoinAddressFamilyType, BitcoinNetworkType } from './bitcoin'; import { @@ -202,6 +203,8 @@ export class FinanceModule extends ModuleBase { * faker.finance.maskedNumber(3) // '(...342)' * * @since 8.0.0 + * + * @deprecated Use `faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*')` or a similar approach instead. */ maskedNumber(length?: number): string; /** @@ -219,6 +222,8 @@ export class FinanceModule extends ModuleBase { * faker.finance.maskedNumber({ length: 3, parens: false, ellipsis: false }) // '298' * * @since 8.0.0 + * + * @deprecated Use `faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*')` or a similar approach instead. */ maskedNumber(options?: { /** @@ -256,6 +261,8 @@ export class FinanceModule extends ModuleBase { * faker.finance.maskedNumber({ length: 3, parens: false, ellipsis: false }) // '298' * * @since 8.0.0 + * + * @deprecated Use `faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*')` or a similar approach instead. */ maskedNumber( optionsOrLength?: @@ -297,6 +304,8 @@ export class FinanceModule extends ModuleBase { * faker.finance.maskedNumber({ length: 3, parens: false, ellipsis: false }) // '298' * * @since 8.0.0 + * + * @deprecated Use `faker.finance.iban().replace(/(?<=.{4})\w(?=.{2})/g, '*')` or a similar approach instead. */ maskedNumber( options: @@ -322,6 +331,14 @@ export class FinanceModule extends ModuleBase { ellipsis?: boolean; } = {} ): string { + deprecated({ + deprecated: 'faker.finance.maskedNumber()', + proposed: + "faker.finance.iban().replace(/(?<=.{4})\\w(?=.{2})/g, '*') or a similar approach", + since: '9.3.0', + until: '10.0.0', + }); + if (typeof options === 'number') { options = { length: options }; } @@ -952,7 +969,7 @@ export class FinanceModule extends ModuleBase { * * @example * faker.finance.transactionDescription() - * // 'invoice transaction at Kilback - Durgan using card ending with ***(...4316) for UAH 783.82 in account ***16168663' + * // 'invoice transaction at Kilback - Durgan using card ending with ************4316 for UAH 783.82 in account ***16168663' * * @since 5.1.0 */ @@ -961,9 +978,9 @@ export class FinanceModule extends ModuleBase { const company = this.faker.company.name(); const transactionType = this.transactionType(); const account = this.accountNumber(); - const card = this.maskedNumber(); + const card = this.creditCardNumber().replaceAll(/.(?=.{4})/g, '*'); const currency = this.currencyCode(); - return `${transactionType} transaction at ${company} using card ending with ***${card} for ${currency} ${amount} in account ***${account}`; + return `${transactionType} transaction at ${company} using card ending with ${card} for ${currency} ${amount} in account ***${account}`; } } |
