Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(number): improve documentation regarding number bounds #2474

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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