diff options
| author | Matt Mayer <[email protected]> | 2023-01-30 20:28:53 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-30 14:28:53 +0100 |
| commit | 1ebbead194a9583dbd0f21f136c9d2bf8f84a50f (patch) | |
| tree | 94a75b885c01a6d16f0655a7fc74d3ffb969a609 /src/modules/color | |
| parent | 0663048932bb1b625fbd5c6988d70bf6b1c0bf61 (diff) | |
| download | faker-1ebbead194a9583dbd0f21f136c9d2bf8f84a50f.tar.xz faker-1ebbead194a9583dbd0f21f136c9d2bf8f84a50f.zip | |
feat(number)!: default to high precision float (#1675)
Diffstat (limited to 'src/modules/color')
| -rw-r--r-- | src/modules/color/index.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/modules/color/index.ts b/src/modules/color/index.ts index 9831d258..981dae60 100644 --- a/src/modules/color/index.ts +++ b/src/modules/color/index.ts @@ -377,7 +377,7 @@ export class ColorModule { color = Array.from({ length: 3 }, () => this.faker.number.int(255)); if (includeAlpha) { - color.push(this.faker.number.float()); + color.push(this.faker.number.float({ precision: 0.01 })); cssFunction = 'rgba'; } @@ -458,7 +458,7 @@ export class ColorModule { }): string | number[]; cmyk(options?: { format?: ColorFormat }): string | number[] { const color: string | number[] = Array.from({ length: 4 }, () => - this.faker.number.float() + this.faker.number.float({ precision: 0.01 }) ); return toColorFormat(color, options?.format || 'decimal', 'cmyk'); } @@ -568,7 +568,7 @@ export class ColorModule { }): string | number[] { const hsl: number[] = [this.faker.number.int(360)]; for (let i = 0; i < (options?.includeAlpha ? 3 : 2); i++) { - hsl.push(this.faker.number.float()); + hsl.push(this.faker.number.float({ precision: 0.01 })); } return toColorFormat( @@ -674,7 +674,7 @@ export class ColorModule { }): string | number[] { const hsl: number[] = [this.faker.number.int(360)]; for (let i = 0; i < 2; i++) { - hsl.push(this.faker.number.float()); + hsl.push(this.faker.number.float({ precision: 0.01 })); } return toColorFormat(hsl, options?.format || 'decimal', 'hwb'); |
