Skip to content

Commit 7b50c2f

Browse files
authored
feat(number): adjust hex default (#1649)
1 parent ab9fa1f commit 7b50c2f

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/modules/number/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ export class NumberModule {
117117
*
118118
* @param options Maximum value or options object. Defaults to `{}`.
119119
* @param options.min Lower bound for generated number. Defaults to `0`.
120-
* @param options.max Upper bound for generated number. Defaults to `min + 16`.
120+
* @param options.max Upper bound for generated number. Defaults to `15`.
121121
*
122122
* @example
123123
* faker.number.hex() // 'b'
124-
* faker.number.hex(16) // '9'
125-
* faker.number.hex({ min: 0, max: 65536 }) // 'af17'
124+
* faker.number.hex(255) // '9d'
125+
* faker.number.hex({ min: 0, max: 65535 }) // 'af17'
126126
*
127127
* @since 8.0.0
128128
*/
@@ -131,7 +131,7 @@ export class NumberModule {
131131
options = { max: options };
132132
}
133133

134-
const { min = 0, max = min + 16 } = options;
134+
const { min = 0, max = 15 } = options;
135135

136136
return this.int({
137137
max,

test/__snapshots__/number.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports[`number > 42 > float > with min, max and precision 1`] = `-0.4261`;
2424

2525
exports[`number > 42 > float > with plain number 1`] = `1.5`;
2626

27-
exports[`number > 42 > hex > noArgs 1`] = `"6"`;
27+
exports[`number > 42 > hex > noArgs 1`] = `"5"`;
2828

2929
exports[`number > 42 > hex > with options 1`] = `"4"`;
3030

@@ -60,7 +60,7 @@ exports[`number > 1211 > float > with min, max and precision 1`] = `61.0658`;
6060

6161
exports[`number > 1211 > float > with plain number 1`] = `3.72`;
6262

63-
exports[`number > 1211 > hex > noArgs 1`] = `"f"`;
63+
exports[`number > 1211 > hex > noArgs 1`] = `"e"`;
6464

6565
exports[`number > 1211 > hex > with options 1`] = `"a"`;
6666

0 commit comments

Comments
 (0)