Skip to content

Commit

Permalink
docs(number): improve documentation regarding number bounds (#2474)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Oct 14, 2023
1 parent e946e6a commit b4fe307
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ export class NumberModule {

/**
* Returns a single random floating-point number for a given precision or range and precision.
* The lower bound is inclusive, the upper bound is exclusive, unless precision is passed.
*
* @param options Upper bound or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0.0`.
* @param options.max Upper bound for generated number. Defaults to `1.0`.
* @param options.precision Precision of the generated number, for example `0.01` will round to 2 decimal points.
* If precision is passed, the upper bound is inclusive.
*
* @example
* faker.number.float() // 0.5688541042618454
Expand Down Expand Up @@ -165,6 +167,7 @@ export class NumberModule {

/**
* Returns a [binary](https://en.wikipedia.org/wiki/Binary_number) number.
* The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
Expand Down Expand Up @@ -213,6 +216,7 @@ export class NumberModule {

/**
* Returns an [octal](https://en.wikipedia.org/wiki/Octal) number.
* The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
Expand Down Expand Up @@ -261,11 +265,14 @@ export class NumberModule {

/**
* Returns a lowercase [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) number.
* The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
* @param options.max Upper bound for generated number. Defaults to `15`.
*
* @throws When options define `max < min`.
*
* @example
* faker.number.hex() // 'b'
* faker.number.hex(255) // '9d'
Expand Down Expand Up @@ -305,6 +312,7 @@ export class NumberModule {

/**
* Returns a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type) number.
* The bounds are inclusive.
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated bigint. Defaults to `0n`.
Expand Down

0 comments on commit b4fe307

Please sign in to comment.