diff options
| author | ST-DDT <[email protected]> | 2023-11-14 17:11:26 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-14 16:11:26 +0000 |
| commit | 7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1 (patch) | |
| tree | bb6813a857c0c42ba1049be5035fce7f45b99c46 /src/modules/finance | |
| parent | 36fc517d17591c8ea1d5135d9a93c7591e3d1f74 (diff) | |
| download | faker-7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1.tar.xz faker-7e3c92e802614ae5e9f621d9e679dfd6f6d63cf1.zip | |
infra: enable strictNullChecks in tsconfig (#2435)
Diffstat (limited to 'src/modules/finance')
| -rw-r--r-- | src/modules/finance/index.ts | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index c443b605..33db26f0 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -24,6 +24,22 @@ export interface Currency { } /** + * Puts a space after every 4 characters. + * + * @internal + * + * @param iban The iban to pretty print. + */ +export function prettyPrintIban(iban: string): string { + let pretty = ''; + for (let i = 0; i < iban.length; i += 4) { + pretty += `${iban.substring(i, i + 4)} `; + } + + return pretty.trimEnd(); +} + +/** * Module to generate finance and money related entries. * * ### Overview @@ -663,9 +679,9 @@ export class FinanceModule extends ModuleBase { */ currencySymbol(): string { let symbol: string; - while (!symbol) { + do { symbol = this.currency().symbol; - } + } while (symbol.length === 0); return symbol; } @@ -1147,7 +1163,7 @@ export class FinanceModule extends ModuleBase { const result = `${ibanFormat.country}${checksum}${s}`; - return formatted ? result.match(/.{1,4}/g).join(' ') : result; + return formatted ? prettyPrintIban(result) : result; } /** |
