forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytes.d.ts
62 lines (53 loc) · 1.59 KB
/
bytes.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Type definitions for bytes v2.1.0
// Project: https://github.com/visionmedia/bytes.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'bytes' {
/**
*Convert the given value in bytes into a string.
*
* @param {number} value
* @param {{
* thousandsSeparator: [string]
* }} [options] bytes options.
*
* @returns {string}
*/
function bytes(value: number, options?: { thousandsSeparator: string }): string;
/**
*Parse string to an integer in bytes.
*
* @param {string} value
* @returns {number}
*/
function bytes(value: string): number;
module bytes {
/**
* Format the given value in bytes into a string.
*
* If the value is negative, take Math.abs(). If it is a float,
* it is rounded.
*
* @param {number} value
* @param {BytesFormatOptions} [options]
*/
function format(value: number, options?: { thousandsSeparator: string }): string;
/**
* Just return the input number value.
*
* @param {number} value
* @return {number}
*/
function parse(value: number): number;
/**
* Parse the string value into an integer in bytes.
*
* If no unit is given, it is assumed the value is in bytes.
*
* @param {string} value
* @return {number}
*/
function parse(value: string): number;
}
export = bytes;
}