1 | # Installation
|
2 | > `npm install --save @types/bytes`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for bytes (https://github.com/visionmedia/bytes.js).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bytes.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bytes/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for bytes 3.1
|
12 | // Project: https://github.com/visionmedia/bytes.js
|
13 | // Definitions by: Zhiyuan Wang <https://github.com/danny8002>
|
14 | // Rickard Laurin <https://github.com/believer>
|
15 | // Florian Keller <https://github.com/ffflorian>
|
16 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
17 |
|
18 | /**
|
19 | * Convert the given value in bytes into a string.
|
20 | */
|
21 | declare function bytes(value: number, options?: bytes.BytesOptions): string;
|
22 |
|
23 | /**
|
24 | * Parse string to an integer in bytes.
|
25 | */
|
26 | declare function bytes(value: string): number;
|
27 |
|
28 | declare namespace bytes {
|
29 | type Unit = 'b' | 'gb' | 'kb' | 'mb' | 'pb' | 'tb' | 'B' | 'GB' | 'KB' | 'MB' | 'PB' | 'TB';
|
30 |
|
31 | interface BytesOptions {
|
32 | decimalPlaces?: number | undefined;
|
33 | fixedDecimals?: boolean | undefined;
|
34 | thousandsSeparator?: string | undefined;
|
35 | unit?: Unit | undefined;
|
36 | unitSeparator?: string | undefined;
|
37 | }
|
38 |
|
39 | /**
|
40 | * Format the given value in bytes into a string.
|
41 | *
|
42 | * If the value is negative, it is kept as such.
|
43 | * If it is a float, it is rounded.
|
44 | */
|
45 | function format(value: number, options?: BytesOptions): string;
|
46 |
|
47 | /**
|
48 | * Parse the string value into an integer in bytes.
|
49 | *
|
50 | * If no unit is given, it is assumed the value is in bytes.
|
51 | */
|
52 | function parse(value: string | number): number;
|
53 | }
|
54 |
|
55 | export = bytes;
|
56 |
|
57 | ````
|
58 |
|
59 | ### Additional Details
|
60 | * Last updated: Tue, 06 Jul 2021 18:05:47 GMT
|
61 | * Dependencies: none
|
62 | * Global values: none
|
63 |
|
64 | # Credits
|
65 | These definitions were written by [Zhiyuan Wang](https://github.com/danny8002), [Rickard Laurin](https://github.com/believer), and [Florian Keller](https://github.com/ffflorian).
|
66 |
|
\ | No newline at end of file |