diff options
| author | Leyla Jähnig <[email protected]> | 2022-11-25 16:59:10 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-25 16:59:10 +0100 |
| commit | 7d4d99f00bf1e29c14346bd6a9fab33c8e7d5743 (patch) | |
| tree | 323754ca575c56ccf688539cfcca66d54c903602 /src/modules/finance | |
| parent | 0af0fff4a410d7531368c709327ba0798a47091a (diff) | |
| download | faker-7d4d99f00bf1e29c14346bd6a9fab33c8e7d5743.tar.xz faker-7d4d99f00bf1e29c14346bd6a9fab33c8e7d5743.zip | |
feat(number): move methods to new module (#1122)
Co-authored-by: ST-DDT <[email protected]>
Co-authored-by: Eric Cheng <[email protected]>
Co-authored-by: Leyla Jähnig <[email protected]>
Co-authored-by: Shinigami92 <[email protected]>
Diffstat (limited to 'src/modules/finance')
| -rw-r--r-- | src/modules/finance/index.ts | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index e739d920..e6533e50 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -143,10 +143,10 @@ export class FinanceModule { symbol: string = '', autoFormat?: boolean ): string { - const randValue = this.faker.datatype.number({ + const randValue = this.faker.number.float({ max, min, - precision: Math.pow(10, -dec), + precision: 10 ** -dec, }); let formattedString: string; @@ -231,7 +231,7 @@ export class FinanceModule { * @since 3.1.0 */ bitcoinAddress(): string { - const addressLength = this.faker.datatype.number({ min: 25, max: 39 }); + const addressLength = this.faker.number.int({ min: 25, max: 39 }); let address = this.faker.helpers.arrayElement(['1', '3']); @@ -253,7 +253,7 @@ export class FinanceModule { * @since 5.0.0 */ litecoinAddress(): string { - const addressLength = this.faker.datatype.number({ min: 26, max: 33 }); + const addressLength = this.faker.number.int({ min: 26, max: 33 }); let address = this.faker.helpers.arrayElement(['L', 'M', '3']); @@ -305,11 +305,7 @@ export class FinanceModule { * @since 5.0.0 */ creditCardCVV(): string { - let cvv = ''; - for (let i = 0; i < 3; i++) { - cvv += this.faker.datatype.number({ max: 9 }).toString(); - } - return cvv; + return this.faker.string.numeric({ length: 3, allowLeadingZeros: true }); } /** @@ -342,7 +338,7 @@ export class FinanceModule { if (length < 1) { throw new FakerError('minimum length is 1'); } - return Array.from({ length }, () => this.faker.datatype.number(9)).join(''); + return this.faker.string.numeric({ length, allowLeadingZeros: true }); } /** @@ -394,7 +390,7 @@ export class FinanceModule { s += this.faker.helpers.arrayElement(iban.alpha); } else if (bban.type === 'c') { if (this.faker.datatype.boolean(0.8)) { - s += this.faker.datatype.number(9); + s += this.faker.number.int(9); } else { s += this.faker.helpers.arrayElement(iban.alpha); } @@ -408,7 +404,7 @@ export class FinanceModule { c--; } } else { - s += this.faker.datatype.number(9); + s += this.faker.number.int(9); } } c--; |
