Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
181
Frontend-Learner/node_modules/pretty-bytes/index.d.ts
generated
vendored
Normal file
181
Frontend-Learner/node_modules/pretty-bytes/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
export type Options = {
|
||||
/**
|
||||
Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly signed?: boolean;
|
||||
|
||||
/**
|
||||
- If `false`: Output won't be localized.
|
||||
- If `true`: Localize the output using the system/browser locale.
|
||||
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
||||
- If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly locale?: boolean | string | readonly string[];
|
||||
|
||||
/**
|
||||
Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337, {bits: true});
|
||||
//=> '1.34 kbit'
|
||||
```
|
||||
*/
|
||||
readonly bits?: boolean;
|
||||
|
||||
/**
|
||||
Format the number using the [Binary Prefix](https://en.wikipedia.org/wiki/Binary_prefix) instead of the [SI Prefix](https://en.wikipedia.org/wiki/SI_prefix). This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1000, {binary: true});
|
||||
//=> '1000 B'
|
||||
|
||||
prettyBytes(1024, {binary: true});
|
||||
//=> '1 KiB'
|
||||
```
|
||||
*/
|
||||
readonly binary?: boolean;
|
||||
|
||||
/**
|
||||
The minimum number of fraction digits to display.
|
||||
|
||||
@default undefined
|
||||
|
||||
If neither `minimumFractionDigits` nor `maximumFractionDigits` is set, the default behavior is to round to 3 significant digits.
|
||||
|
||||
Note: When `minimumFractionDigits` or `maximumFractionDigits` is specified, values are truncated instead of rounded to provide more intuitive results for file sizes.
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
// Show the number with at least 3 fractional digits
|
||||
prettyBytes(1900, {minimumFractionDigits: 3});
|
||||
//=> '1.900 kB'
|
||||
|
||||
prettyBytes(1900);
|
||||
//=> '1.9 kB'
|
||||
```
|
||||
*/
|
||||
readonly minimumFractionDigits?: number;
|
||||
|
||||
/**
|
||||
The maximum number of fraction digits to display.
|
||||
|
||||
@default undefined
|
||||
|
||||
If neither `minimumFractionDigits` nor `maximumFractionDigits` is set, the default behavior is to round to 3 significant digits.
|
||||
|
||||
Note: When `minimumFractionDigits` or `maximumFractionDigits` is specified, values are truncated instead of rounded to provide more intuitive results for file sizes.
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
// Show the number with at most 1 fractional digit
|
||||
prettyBytes(1920, {maximumFractionDigits: 1});
|
||||
//=> '1.9 kB'
|
||||
|
||||
prettyBytes(1920);
|
||||
//=> '1.92 kB'
|
||||
```
|
||||
*/
|
||||
readonly maximumFractionDigits?: number;
|
||||
|
||||
/**
|
||||
Put a space between the number and unit.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1920, {space: false});
|
||||
//=> '1.92kB'
|
||||
|
||||
prettyBytes(1920);
|
||||
//=> '1.92 kB'
|
||||
```
|
||||
*/
|
||||
readonly space?: boolean;
|
||||
|
||||
/**
|
||||
Use a non-breaking space instead of a regular space to prevent the unit from wrapping to a new line.
|
||||
|
||||
Has no effect when `space` is `false`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly nonBreakingSpace?: boolean;
|
||||
|
||||
/**
|
||||
Pad the output to a fixed width by right-aligning it.
|
||||
|
||||
Useful for creating aligned columns in tables or progress bars.
|
||||
|
||||
If the output is longer than the specified width, no padding is applied.
|
||||
|
||||
Must be a non-negative integer. Throws a `TypeError` for invalid values.
|
||||
|
||||
@default undefined
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337, {fixedWidth: 10});
|
||||
//=> ' 1.34 kB'
|
||||
|
||||
prettyBytes(100_000, {fixedWidth: 10});
|
||||
//=> ' 100 kB'
|
||||
|
||||
// Useful for progress bars and tables
|
||||
[1000, 10_000, 100_000].map(bytes => prettyBytes(bytes, {fixedWidth: 8}));
|
||||
//=> [' 1 kB', ' 10 kB', ' 100 kB']
|
||||
```
|
||||
*/
|
||||
readonly fixedWidth?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
||||
|
||||
@param number - The number to format.
|
||||
|
||||
@example
|
||||
```
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337);
|
||||
//=> '1.34 kB'
|
||||
|
||||
prettyBytes(100);
|
||||
//=> '100 B'
|
||||
|
||||
// Display file size differences
|
||||
prettyBytes(42, {signed: true});
|
||||
//=> '+42 B'
|
||||
|
||||
// Localized output using German locale
|
||||
prettyBytes(1337, {locale: 'de'});
|
||||
//=> '1,34 kB'
|
||||
```
|
||||
*/
|
||||
export default function prettyBytes(
|
||||
number: number | bigint,
|
||||
options?: Options
|
||||
): string;
|
||||
178
Frontend-Learner/node_modules/pretty-bytes/index.js
generated
vendored
Normal file
178
Frontend-Learner/node_modules/pretty-bytes/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
const BYTE_UNITS = [
|
||||
'B',
|
||||
'kB',
|
||||
'MB',
|
||||
'GB',
|
||||
'TB',
|
||||
'PB',
|
||||
'EB',
|
||||
'ZB',
|
||||
'YB',
|
||||
];
|
||||
|
||||
const BIBYTE_UNITS = [
|
||||
'B',
|
||||
'KiB',
|
||||
'MiB',
|
||||
'GiB',
|
||||
'TiB',
|
||||
'PiB',
|
||||
'EiB',
|
||||
'ZiB',
|
||||
'YiB',
|
||||
];
|
||||
|
||||
const BIT_UNITS = [
|
||||
'b',
|
||||
'kbit',
|
||||
'Mbit',
|
||||
'Gbit',
|
||||
'Tbit',
|
||||
'Pbit',
|
||||
'Ebit',
|
||||
'Zbit',
|
||||
'Ybit',
|
||||
];
|
||||
|
||||
const BIBIT_UNITS = [
|
||||
'b',
|
||||
'kibit',
|
||||
'Mibit',
|
||||
'Gibit',
|
||||
'Tibit',
|
||||
'Pibit',
|
||||
'Eibit',
|
||||
'Zibit',
|
||||
'Yibit',
|
||||
];
|
||||
|
||||
/*
|
||||
Formats the given number using `Number#toLocaleString`.
|
||||
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
||||
- If locale is true, the system default locale is used for translation.
|
||||
- If no value for locale is specified, the number is returned unmodified.
|
||||
*/
|
||||
const toLocaleString = (number, locale, options) => {
|
||||
let result = number;
|
||||
if (typeof locale === 'string' || Array.isArray(locale)) {
|
||||
result = number.toLocaleString(locale, options);
|
||||
} else if (locale === true || options !== undefined) {
|
||||
result = number.toLocaleString(undefined, options);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const log10 = numberOrBigInt => {
|
||||
if (typeof numberOrBigInt === 'number') {
|
||||
return Math.log10(numberOrBigInt);
|
||||
}
|
||||
|
||||
const string = numberOrBigInt.toString(10);
|
||||
|
||||
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
||||
};
|
||||
|
||||
const log = numberOrBigInt => {
|
||||
if (typeof numberOrBigInt === 'number') {
|
||||
return Math.log(numberOrBigInt);
|
||||
}
|
||||
|
||||
return log10(numberOrBigInt) * Math.log(10);
|
||||
};
|
||||
|
||||
const divide = (numberOrBigInt, divisor) => {
|
||||
if (typeof numberOrBigInt === 'number') {
|
||||
return numberOrBigInt / divisor;
|
||||
}
|
||||
|
||||
const integerPart = numberOrBigInt / BigInt(divisor);
|
||||
const remainder = numberOrBigInt % BigInt(divisor);
|
||||
return Number(integerPart) + (Number(remainder) / divisor);
|
||||
};
|
||||
|
||||
const applyFixedWidth = (result, fixedWidth) => {
|
||||
if (fixedWidth === undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (typeof fixedWidth !== 'number' || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) {
|
||||
throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
||||
}
|
||||
|
||||
if (fixedWidth === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return result.length < fixedWidth ? result.padStart(fixedWidth, ' ') : result;
|
||||
};
|
||||
|
||||
const buildLocaleOptions = options => {
|
||||
const {minimumFractionDigits, maximumFractionDigits} = options;
|
||||
|
||||
if (minimumFractionDigits === undefined && maximumFractionDigits === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...(minimumFractionDigits !== undefined && {minimumFractionDigits}),
|
||||
...(maximumFractionDigits !== undefined && {maximumFractionDigits}),
|
||||
roundingMode: 'trunc',
|
||||
};
|
||||
};
|
||||
|
||||
export default function prettyBytes(number, options) {
|
||||
if (typeof number !== 'bigint' && !Number.isFinite(number)) {
|
||||
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
||||
}
|
||||
|
||||
options = {
|
||||
bits: false,
|
||||
binary: false,
|
||||
space: true,
|
||||
nonBreakingSpace: false,
|
||||
...options,
|
||||
};
|
||||
|
||||
const UNITS = options.bits
|
||||
? (options.binary ? BIBIT_UNITS : BIT_UNITS)
|
||||
: (options.binary ? BIBYTE_UNITS : BYTE_UNITS);
|
||||
|
||||
const separator = options.space ? (options.nonBreakingSpace ? '\u00A0' : ' ') : '';
|
||||
|
||||
// Handle signed zero case
|
||||
const isZero = typeof number === 'number' ? number === 0 : number === 0n;
|
||||
if (options.signed && isZero) {
|
||||
const result = ` 0${separator}${UNITS[0]}`;
|
||||
return applyFixedWidth(result, options.fixedWidth);
|
||||
}
|
||||
|
||||
const isNegative = number < 0;
|
||||
const prefix = isNegative ? '-' : (options.signed ? '+' : '');
|
||||
|
||||
if (isNegative) {
|
||||
number = -number;
|
||||
}
|
||||
|
||||
const localeOptions = buildLocaleOptions(options);
|
||||
let result;
|
||||
|
||||
if (number < 1) {
|
||||
const numberString = toLocaleString(number, options.locale, localeOptions);
|
||||
result = prefix + numberString + separator + UNITS[0];
|
||||
} else {
|
||||
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
||||
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
||||
|
||||
if (!localeOptions) {
|
||||
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
||||
number = number.toPrecision(minPrecision);
|
||||
}
|
||||
|
||||
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
||||
const unit = UNITS[exponent];
|
||||
result = prefix + numberString + separator + unit;
|
||||
}
|
||||
|
||||
return applyFixedWidth(result, options.fixedWidth);
|
||||
}
|
||||
9
Frontend-Learner/node_modules/pretty-bytes/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/pretty-bytes/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
50
Frontend-Learner/node_modules/pretty-bytes/package.json
generated
vendored
Normal file
50
Frontend-Learner/node_modules/pretty-bytes/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"name": "pretty-bytes",
|
||||
"version": "7.1.0",
|
||||
"description": "Convert bytes to a human readable string: 1337 → 1.34 kB",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/pretty-bytes",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"pretty",
|
||||
"bytes",
|
||||
"byte",
|
||||
"filesize",
|
||||
"size",
|
||||
"file",
|
||||
"human",
|
||||
"humanized",
|
||||
"readable",
|
||||
"si",
|
||||
"data",
|
||||
"locale",
|
||||
"localization",
|
||||
"localized"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^6.2.0",
|
||||
"tsd": "^0.32.0",
|
||||
"xo": "^0.60.0"
|
||||
}
|
||||
}
|
||||
217
Frontend-Learner/node_modules/pretty-bytes/readme.md
generated
vendored
Normal file
217
Frontend-Learner/node_modules/pretty-bytes/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
# pretty-bytes
|
||||
|
||||
> Convert bytes to a human readable string: `1337` → `1.34 kB`
|
||||
|
||||
Useful for displaying file sizes for humans.
|
||||
|
||||
*Note that it uses base-10 (e.g. kilobyte).
|
||||
[Read about the difference between kilobyte and kibibyte.](https://web.archive.org/web/20150324153922/https://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)*
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install pretty-bytes
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337);
|
||||
//=> '1.34 kB'
|
||||
|
||||
prettyBytes(100);
|
||||
//=> '100 B'
|
||||
|
||||
// Display with units of bits
|
||||
prettyBytes(1337, {bits: true});
|
||||
//=> '1.34 kbit'
|
||||
|
||||
// Display file size differences
|
||||
prettyBytes(42, {signed: true});
|
||||
//=> '+42 B'
|
||||
|
||||
// Localized output using German locale
|
||||
prettyBytes(1337, {locale: 'de'});
|
||||
//=> '1,34 kB'
|
||||
|
||||
// Fixed width for alignment (useful for progress bars and tables)
|
||||
prettyBytes(1337, {fixedWidth: 8});
|
||||
//=> ' 1.34 kB'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### prettyBytes(number, options?)
|
||||
|
||||
#### number
|
||||
|
||||
Type: `number | bigint`
|
||||
|
||||
The number to format.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### signed
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
|
||||
|
||||
##### bits
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337, {bits: true});
|
||||
//=> '1.34 kbit'
|
||||
```
|
||||
|
||||
##### binary
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Format the number using the [Binary Prefix](https://en.wikipedia.org/wiki/Binary_prefix) instead of the [SI Prefix](https://en.wikipedia.org/wiki/SI_prefix). This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1000, {binary: true});
|
||||
//=> '1000 B'
|
||||
|
||||
prettyBytes(1024, {binary: true});
|
||||
//=> '1 KiB'
|
||||
```
|
||||
|
||||
##### locale
|
||||
|
||||
Type: `boolean | string | string[]`\
|
||||
Default: `false`
|
||||
|
||||
- If `false`: Output won't be localized.
|
||||
- If `true`: Localize the output using the system/browser locale.
|
||||
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
||||
- If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Only the number and decimal separator are localized. The unit title is not and will not be localized.
|
||||
|
||||
##### minimumFractionDigits
|
||||
|
||||
Type: `number`\
|
||||
Default: `undefined`
|
||||
|
||||
The minimum number of fraction digits to display.
|
||||
|
||||
If neither `minimumFractionDigits` nor `maximumFractionDigits` is set, the default behavior is to round to 3 significant digits.
|
||||
|
||||
> [!NOTE]
|
||||
> When `minimumFractionDigits` or `maximumFractionDigits` is specified, values are truncated instead of rounded to provide more intuitive results for file sizes.
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
// Show the number with at least 3 fractional digits
|
||||
prettyBytes(1900, {minimumFractionDigits: 3});
|
||||
//=> '1.900 kB'
|
||||
|
||||
prettyBytes(1900);
|
||||
//=> '1.9 kB'
|
||||
```
|
||||
|
||||
##### maximumFractionDigits
|
||||
|
||||
Type: `number`\
|
||||
Default: `undefined`
|
||||
|
||||
The maximum number of fraction digits to display.
|
||||
|
||||
If neither `minimumFractionDigits` nor `maximumFractionDigits` is set, the default behavior is to round to 3 significant digits.
|
||||
|
||||
> [!NOTE]
|
||||
> When `minimumFractionDigits` or `maximumFractionDigits` is specified, values are truncated instead of rounded to provide more intuitive results for file sizes.
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
// Show the number with at most 1 fractional digit
|
||||
prettyBytes(1920, {maximumFractionDigits: 1});
|
||||
//=> '1.9 kB'
|
||||
|
||||
prettyBytes(1920);
|
||||
//=> '1.92 kB'
|
||||
```
|
||||
|
||||
##### space
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Put a space between the number and unit.
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1920, {space: false});
|
||||
//=> '1.92kB'
|
||||
|
||||
prettyBytes(1920);
|
||||
//=> '1.92 kB'
|
||||
```
|
||||
|
||||
##### nonBreakingSpace
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Use a non-breaking space instead of a regular space to prevent the unit from wrapping to a new line.
|
||||
|
||||
Has no effect when `space` is `false`.
|
||||
|
||||
##### fixedWidth
|
||||
|
||||
Type: `number`\
|
||||
Default: `undefined`
|
||||
|
||||
Pad the output to a fixed width by right-aligning it.
|
||||
|
||||
Useful for creating aligned columns in tables or progress bars.
|
||||
|
||||
If the output is longer than the specified width, no padding is applied.
|
||||
|
||||
Must be a non-negative integer. Throws a `TypeError` for invalid values.
|
||||
|
||||
```js
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
prettyBytes(1337, {fixedWidth: 10});
|
||||
//=> ' 1.34 kB'
|
||||
|
||||
prettyBytes(100_000, {fixedWidth: 10});
|
||||
//=> ' 100 kB'
|
||||
|
||||
// Useful for progress bars and tables
|
||||
[1000, 10_000, 100_000].map(bytes => prettyBytes(bytes, {fixedWidth: 8}));
|
||||
//=> [' 1 kB', ' 10 kB', ' 100 kB']
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why kB and not KB?
|
||||
|
||||
`k` is the [standardized SI prefix](https://en.wikipedia.org/wiki/Metric_prefix) for kilo.
|
||||
|
||||
## Related
|
||||
|
||||
- [pretty-bytes-cli](https://github.com/sindresorhus/pretty-bytes-cli) - CLI for this module
|
||||
- [pretty-ms](https://github.com/sindresorhus/pretty-ms) - Convert milliseconds to a human readable string
|
||||
Loading…
Add table
Add a link
Reference in a new issue