forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytes.d.ts
67 lines (59 loc) · 1.71 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
63
64
65
66
67
// Type definitions for bytes v2.4.0
// Project: https://github.com/visionmedia/bytes.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'bytes' {
interface BytesOptions {
decimalPlaces?: number,
thousandsSeparator?: string,
unitSeparator?: string,
fixedDecimals?: boolean
}
/**
*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?: BytesOptions): string;
/**
*Parse string to an integer in bytes.
*
* @param {string} value
* @returns {number}
*/
function bytes(value: string): number;
namespace 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?: BytesOptions): 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;
}