Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ filesize(1, {symbols: {B: "Б"}}); // "1 Б"

// BigInt
filesize(BigInt(1024)); // "1.02 kB"
filesize(1024n ** 6n, {standard: "iec"}); // "1 EiB" (above Number.MAX_SAFE_INTEGER)

// Negative numbers
filesize(-1024); // "-1.02 kB"
Expand All @@ -149,7 +150,7 @@ try {
}
```

Invalid input includes non-numeric values, `NaN`, `Infinity`, and BigInt values that overflow `Number.MAX_SAFE_INTEGER`.
Invalid input includes non-numeric values, `NaN`, `Infinity`, and BigInt values whose conversion to `Number` is non-finite (for example, `10n ** 309n`). BigInt values above `Number.MAX_SAFE_INTEGER` are supported.

## TypeScript

Expand Down
3 changes: 2 additions & 1 deletion dist/filesize.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ function formatOutput(result, e, u, output, spacer) {
* (`"0x1F"`), binary (`"0b101"`), and octal (`"0o17"`) literals are parsed;
* `null`, `""`, `" "`, `true`, `false`, and single-element arrays coerce to
* their numeric value. `undefined`, `"1_000"`, and `"1000n"` throw `TypeError`.
* A `bigint` that overflows `Number.MAX_SAFE_INTEGER` throws `TypeError`.
* BigInt values above `Number.MAX_SAFE_INTEGER` are supported. A `bigint`
* whose conversion to `Number` is non-finite throws `TypeError`.
*
* **Option precedence:** When multiple options conflict, `standard` wins over
* `base`; `fullform` wins over `symbols`; `locale` wins over `separator`;
Expand Down
3 changes: 2 additions & 1 deletion dist/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ function formatOutput(result, e, u, output, spacer) {
* (`"0x1F"`), binary (`"0b101"`), and octal (`"0o17"`) literals are parsed;
* `null`, `""`, `" "`, `true`, `false`, and single-element arrays coerce to
* their numeric value. `undefined`, `"1_000"`, and `"1000n"` throw `TypeError`.
* A `bigint` that overflows `Number.MAX_SAFE_INTEGER` throws `TypeError`.
* BigInt values above `Number.MAX_SAFE_INTEGER` are supported. A `bigint`
* whose conversion to `Number` is non-finite throws `TypeError`.
*
* **Option precedence:** When multiple options conflict, `standard` wins over
* `base`; `fullform` wins over `symbols`; `locale` wins over `separator`;
Expand Down
2 changes: 1 addition & 1 deletion dist/filesize.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/filesize.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ function formatOutput(result, e, u, output, spacer) {
* (`"0x1F"`), binary (`"0b101"`), and octal (`"0o17"`) literals are parsed;
* `null`, `""`, `" "`, `true`, `false`, and single-element arrays coerce to
* their numeric value. `undefined`, `"1_000"`, and `"1000n"` throw `TypeError`.
* A `bigint` that overflows `Number.MAX_SAFE_INTEGER` throws `TypeError`.
* BigInt values above `Number.MAX_SAFE_INTEGER` are supported. A `bigint`
* whose conversion to `Number` is non-finite throws `TypeError`.
*
* **Option precedence:** When multiple options conflict, `standard` wins over
* `base`; `fullform` wins over `symbols`; `locale` wins over `separator`;
Expand Down
2 changes: 1 addition & 1 deletion dist/filesize.umd.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ import {
* (`"0x1F"`), binary (`"0b101"`), and octal (`"0o17"`) literals are parsed;
* `null`, `""`, `" "`, `true`, `false`, and single-element arrays coerce to
* their numeric value. `undefined`, `"1_000"`, and `"1000n"` throw `TypeError`.
* A `bigint` that overflows `Number.MAX_SAFE_INTEGER` throws `TypeError`.
* BigInt values above `Number.MAX_SAFE_INTEGER` are supported. A `bigint`
* whose conversion to `Number` is non-finite throws `TypeError`.
*
* **Option precedence:** When multiple options conflict, `standard` wins over
* `base`; `fullform` wins over `symbols`; `locale` wins over `separator`;
Expand Down
Loading