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

Add ability to control number of fractional digits #62

Merged
merged 11 commits into from
Feb 21, 2021
Prev Previous commit
Update index.d.ts
  • Loading branch information
sindresorhus authored Feb 21, 2021
commit 5efb81b3ad7834036cce9d350aaf0a481cf05ef0
14 changes: 10 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ declare namespace prettyBytes {
readonly binary?: boolean;

/**
The minimum number of fraction digits to display. If neither `minimumFractionDigits` or `maximumFractionDigits` are set the default behavior is round to 3 significant digits.
The minimum number of fraction digits to display.

If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.

@default undefined

```
import prettyBytes = require('pretty-bytes');

// Show number with at least 3 fractional digits
// Show the number with at least 3 fractional digits
prettyBytes(1900, {minimumFractionDigits: 3});
//=> '1.900 kB'

prettyBytes(1900);
//=> '1.9 kB'
```
Expand All @@ -71,16 +74,19 @@ declare namespace prettyBytes {


/**
The maximum number of fraction digits to display. If neither `minimumFractionDigits` or `maximumFractionDigits` are set the default behavior is round to 3 significant digits.
The maximum number of fraction digits to display.

If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.

@default undefined

```
import prettyBytes = require('pretty-bytes');

// Show number with at most 1 fractional digit
// Show the number with at most 1 fractional digit
prettyBytes(1920, {maximumFractionDigits: 1});
//=> '1.9 kB'

prettyBytes(1920);
//=> '1.92 kB'
```
Expand Down