forked from dankogai/js-base64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64.d.ts
135 lines (135 loc) · 3.86 KB
/
base64.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* base64.ts
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*
* @author Dan Kogai (https://github.com/dankogai)
*/
declare const version = "3.7.2";
/**
* @deprecated use lowercase `version`.
*/
declare const VERSION = "3.7.2";
/**
* polyfill version of `btoa`
*/
declare const btoaPolyfill: (bin: string) => string;
/**
* does what `window.btoa` of web browsers do.
* @param {String} bin binary string
* @returns {string} Base64-encoded string
*/
declare const _btoa: (bin: string) => string;
/**
* converts a Uint8Array to a Base64 string.
* @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
* @returns {string} Base64 string
*/
declare const fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
/**
* @deprecated should have been internal use only.
* @param {string} src UTF-8 string
* @returns {string} UTF-16 string
*/
declare const utob: (u: string) => string;
/**
* converts a UTF-8-encoded string to a Base64 string.
* @param {boolean} [urlsafe] if `true` make the result URL-safe
* @returns {string} Base64 string
*/
declare const encode: (src: string, urlsafe?: boolean) => string;
/**
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
* @returns {string} Base64 string
*/
declare const encodeURI: (src: string) => string;
/**
* @deprecated should have been internal use only.
* @param {string} src UTF-16 string
* @returns {string} UTF-8 string
*/
declare const btou: (b: string) => string;
/**
* polyfill version of `atob`
*/
declare const atobPolyfill: (asc: string) => string;
/**
* does what `window.atob` of web browsers do.
* @param {String} asc Base64-encoded string
* @returns {string} binary string
*/
declare const _atob: (asc: string) => string;
/**
* converts a Base64 string to a Uint8Array.
*/
declare const toUint8Array: (a: string) => Uint8Array;
/**
* converts a Base64 string to a UTF-8 string.
* @param {String} src Base64 string. Both normal and URL-safe are supported
* @returns {string} UTF-8 string
*/
declare const decode: (src: string) => string;
/**
* check if a value is a valid Base64 string
* @param {String} src a value to check
*/
declare const isValid: (src: any) => boolean;
/**
* extend String.prototype with relevant methods
*/
declare const extendString: () => void;
/**
* extend Uint8Array.prototype with relevant methods
*/
declare const extendUint8Array: () => void;
/**
* extend Builtin prototypes with relevant methods
*/
declare const extendBuiltins: () => void;
declare const gBase64: {
version: string;
VERSION: string;
atob: (asc: string) => string;
atobPolyfill: (asc: string) => string;
btoa: (bin: string) => string;
btoaPolyfill: (bin: string) => string;
fromBase64: (src: string) => string;
toBase64: (src: string, urlsafe?: boolean) => string;
encode: (src: string, urlsafe?: boolean) => string;
encodeURI: (src: string) => string;
encodeURL: (src: string) => string;
utob: (u: string) => string;
btou: (b: string) => string;
decode: (src: string) => string;
isValid: (src: any) => boolean;
fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
toUint8Array: (a: string) => Uint8Array;
extendString: () => void;
extendUint8Array: () => void;
extendBuiltins: () => void;
};
export { version };
export { VERSION };
export { _atob as atob };
export { atobPolyfill };
export { _btoa as btoa };
export { btoaPolyfill };
export { decode as fromBase64 };
export { encode as toBase64 };
export { utob };
export { encode };
export { encodeURI };
export { encodeURI as encodeURL };
export { btou };
export { decode };
export { isValid };
export { fromUint8Array };
export { toUint8Array };
export { extendString };
export { extendUint8Array };
export { extendBuiltins };
export { gBase64 as Base64 };