source: trip-planner-front/node_modules/pretty-bytes/index.d.ts@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.3 KB
Line 
1declare namespace prettyBytes {
2 interface Options {
3 /**
4 Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
5
6 @default false
7 */
8 readonly signed?: boolean;
9
10 /**
11 - If `false`: Output won't be localized.
12 - If `true`: Localize the output using the system/browser locale.
13 - If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
14 - If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
15
16 __Note:__ Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime.
17
18 @default false
19 */
20 readonly locale?: boolean | string | readonly string[];
21
22 /**
23 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).
24
25 @default false
26
27 @example
28 ```
29 import prettyBytes = require('pretty-bytes');
30
31 prettyBytes(1337, {bits: true});
32 //=> '1.34 kbit'
33 ```
34 */
35 readonly bits?: boolean;
36
37 /**
38 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.
39
40 @default false
41
42 @example
43 ```
44 import prettyBytes = require('pretty-bytes');
45
46 prettyBytes(1000, {binary: true});
47 //=> '1000 bit'
48
49 prettyBytes(1024, {binary: true});
50 //=> '1 kiB'
51 ```
52 */
53 readonly binary?: boolean;
54
55 /**
56 The minimum number of fraction digits to display.
57
58 If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
59
60 @default undefined
61
62 ```
63 import prettyBytes = require('pretty-bytes');
64
65 // Show the number with at least 3 fractional digits
66 prettyBytes(1900, {minimumFractionDigits: 3});
67 //=> '1.900 kB'
68
69 prettyBytes(1900);
70 //=> '1.9 kB'
71 ```
72 */
73 readonly minimumFractionDigits?: number;
74
75
76 /**
77 The maximum number of fraction digits to display.
78
79 If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
80
81 @default undefined
82
83 ```
84 import prettyBytes = require('pretty-bytes');
85
86 // Show the number with at most 1 fractional digit
87 prettyBytes(1920, {maximumFractionDigits: 1});
88 //=> '1.9 kB'
89
90 prettyBytes(1920);
91 //=> '1.92 kB'
92 ```
93 */
94 readonly maximumFractionDigits?: number;
95 }
96}
97
98/**
99Convert bytes to a human readable string: `1337` → `1.34 kB`.
100
101@param number - The number to format.
102
103@example
104```
105import prettyBytes = require('pretty-bytes');
106
107prettyBytes(1337);
108//=> '1.34 kB'
109
110prettyBytes(100);
111//=> '100 B'
112
113// Display file size differences
114prettyBytes(42, {signed: true});
115//=> '+42 B'
116
117// Localized output using German locale
118prettyBytes(1337, {locale: 'de'});
119//=> '1,34 kB'
120```
121*/
122declare function prettyBytes(
123 number: number,
124 options?: prettyBytes.Options
125): string;
126
127export = prettyBytes;
Note: See TracBrowser for help on using the repository browser.