js-base64 3.7.5 → 3.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/base64.d.mts +135 -0
- package/base64.d.ts +2 -2
- package/base64.js +3 -5
- package/base64.mjs +4 -6
- package/package.json +41 -36
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Locally…
|
|
|
25
25
|
… or Directly from CDN. In which case you don't even need to install.
|
|
26
26
|
|
|
27
27
|
```html
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.7.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.7.7/base64.min.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
This good old way loads `Base64` in the global context (`window`). Though `Base64.noConflict()` is made available, you should consider using ES6 Module to avoid tainting `window`.
|
|
@@ -48,14 +48,14 @@ or even remotely.
|
|
|
48
48
|
```html
|
|
49
49
|
<script type="module">
|
|
50
50
|
// note jsdelivr.net does not automatically minify .mjs
|
|
51
|
-
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.
|
|
51
|
+
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.7/base64.mjs';
|
|
52
52
|
</script>
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
```html
|
|
56
56
|
<script type="module">
|
|
57
57
|
// or if you prefer no Base64 namespace
|
|
58
|
-
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.
|
|
58
|
+
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.7/base64.mjs';
|
|
59
59
|
</script>
|
|
60
60
|
```
|
|
61
61
|
|
package/base64.d.mts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* base64.ts
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the BSD 3-Clause License.
|
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*
|
|
7
|
+
* References:
|
|
8
|
+
* http://en.wikipedia.org/wiki/Base64
|
|
9
|
+
*
|
|
10
|
+
* @author Dan Kogai (https://github.com/dankogai)
|
|
11
|
+
*/
|
|
12
|
+
declare const version = "3.7.7";
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated use lowercase `version`.
|
|
15
|
+
*/
|
|
16
|
+
declare const VERSION = "3.7.7";
|
|
17
|
+
/**
|
|
18
|
+
* polyfill version of `btoa`
|
|
19
|
+
*/
|
|
20
|
+
declare const btoaPolyfill: (bin: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* does what `window.btoa` of web browsers do.
|
|
23
|
+
* @param {String} bin binary string
|
|
24
|
+
* @returns {string} Base64-encoded string
|
|
25
|
+
*/
|
|
26
|
+
declare const _btoa: (bin: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* converts a Uint8Array to a Base64 string.
|
|
29
|
+
* @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
|
|
30
|
+
* @returns {string} Base64 string
|
|
31
|
+
*/
|
|
32
|
+
declare const fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated should have been internal use only.
|
|
35
|
+
* @param {string} src UTF-8 string
|
|
36
|
+
* @returns {string} UTF-16 string
|
|
37
|
+
*/
|
|
38
|
+
declare const utob: (u: string) => string;
|
|
39
|
+
/**
|
|
40
|
+
* converts a UTF-8-encoded string to a Base64 string.
|
|
41
|
+
* @param {boolean} [urlsafe] if `true` make the result URL-safe
|
|
42
|
+
* @returns {string} Base64 string
|
|
43
|
+
*/
|
|
44
|
+
declare const encode: (src: string, urlsafe?: boolean) => string;
|
|
45
|
+
/**
|
|
46
|
+
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
|
|
47
|
+
* @returns {string} Base64 string
|
|
48
|
+
*/
|
|
49
|
+
declare const encodeURI: (src: string) => string;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated should have been internal use only.
|
|
52
|
+
* @param {string} src UTF-16 string
|
|
53
|
+
* @returns {string} UTF-8 string
|
|
54
|
+
*/
|
|
55
|
+
declare const btou: (b: string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* polyfill version of `atob`
|
|
58
|
+
*/
|
|
59
|
+
declare const atobPolyfill: (asc: string) => string;
|
|
60
|
+
/**
|
|
61
|
+
* does what `window.atob` of web browsers do.
|
|
62
|
+
* @param {String} asc Base64-encoded string
|
|
63
|
+
* @returns {string} binary string
|
|
64
|
+
*/
|
|
65
|
+
declare const _atob: (asc: string) => string;
|
|
66
|
+
/**
|
|
67
|
+
* converts a Base64 string to a Uint8Array.
|
|
68
|
+
*/
|
|
69
|
+
declare const toUint8Array: (a: string) => Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* converts a Base64 string to a UTF-8 string.
|
|
72
|
+
* @param {String} src Base64 string. Both normal and URL-safe are supported
|
|
73
|
+
* @returns {string} UTF-8 string
|
|
74
|
+
*/
|
|
75
|
+
declare const decode: (src: string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* check if a value is a valid Base64 string
|
|
78
|
+
* @param {String} src a value to check
|
|
79
|
+
*/
|
|
80
|
+
declare const isValid: (src: any) => boolean;
|
|
81
|
+
/**
|
|
82
|
+
* extend String.prototype with relevant methods
|
|
83
|
+
*/
|
|
84
|
+
declare const extendString: () => void;
|
|
85
|
+
/**
|
|
86
|
+
* extend Uint8Array.prototype with relevant methods
|
|
87
|
+
*/
|
|
88
|
+
declare const extendUint8Array: () => void;
|
|
89
|
+
/**
|
|
90
|
+
* extend Builtin prototypes with relevant methods
|
|
91
|
+
*/
|
|
92
|
+
declare const extendBuiltins: () => void;
|
|
93
|
+
declare const gBase64: {
|
|
94
|
+
version: string;
|
|
95
|
+
VERSION: string;
|
|
96
|
+
atob: (asc: string) => string;
|
|
97
|
+
atobPolyfill: (asc: string) => string;
|
|
98
|
+
btoa: (bin: string) => string;
|
|
99
|
+
btoaPolyfill: (bin: string) => string;
|
|
100
|
+
fromBase64: (src: string) => string;
|
|
101
|
+
toBase64: (src: string, urlsafe?: boolean) => string;
|
|
102
|
+
encode: (src: string, urlsafe?: boolean) => string;
|
|
103
|
+
encodeURI: (src: string) => string;
|
|
104
|
+
encodeURL: (src: string) => string;
|
|
105
|
+
utob: (u: string) => string;
|
|
106
|
+
btou: (b: string) => string;
|
|
107
|
+
decode: (src: string) => string;
|
|
108
|
+
isValid: (src: any) => boolean;
|
|
109
|
+
fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
|
|
110
|
+
toUint8Array: (a: string) => Uint8Array;
|
|
111
|
+
extendString: () => void;
|
|
112
|
+
extendUint8Array: () => void;
|
|
113
|
+
extendBuiltins: () => void;
|
|
114
|
+
};
|
|
115
|
+
export { version };
|
|
116
|
+
export { VERSION };
|
|
117
|
+
export { _atob as atob };
|
|
118
|
+
export { atobPolyfill };
|
|
119
|
+
export { _btoa as btoa };
|
|
120
|
+
export { btoaPolyfill };
|
|
121
|
+
export { decode as fromBase64 };
|
|
122
|
+
export { encode as toBase64 };
|
|
123
|
+
export { utob };
|
|
124
|
+
export { encode };
|
|
125
|
+
export { encodeURI };
|
|
126
|
+
export { encodeURI as encodeURL };
|
|
127
|
+
export { btou };
|
|
128
|
+
export { decode };
|
|
129
|
+
export { isValid };
|
|
130
|
+
export { fromUint8Array };
|
|
131
|
+
export { toUint8Array };
|
|
132
|
+
export { extendString };
|
|
133
|
+
export { extendUint8Array };
|
|
134
|
+
export { extendBuiltins };
|
|
135
|
+
export { gBase64 as Base64 };
|
package/base64.d.ts
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
11
11
|
*/
|
|
12
|
-
declare const version = "3.7.
|
|
12
|
+
declare const version = "3.7.7";
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use lowercase `version`.
|
|
15
15
|
*/
|
|
16
|
-
declare const VERSION = "3.7.
|
|
16
|
+
declare const VERSION = "3.7.7";
|
|
17
17
|
/**
|
|
18
18
|
* polyfill version of `btoa`
|
|
19
19
|
*/
|
package/base64.js
CHANGED
|
@@ -37,13 +37,11 @@
|
|
|
37
37
|
*
|
|
38
38
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
39
39
|
*/
|
|
40
|
-
var version = '3.7.
|
|
40
|
+
var version = '3.7.7';
|
|
41
41
|
/**
|
|
42
42
|
* @deprecated use lowercase `version`.
|
|
43
43
|
*/
|
|
44
44
|
var VERSION = version;
|
|
45
|
-
var _hasatob = typeof atob === 'function';
|
|
46
|
-
var _hasbtoa = typeof btoa === 'function';
|
|
47
45
|
var _hasBuffer = typeof Buffer === 'function';
|
|
48
46
|
var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
|
|
49
47
|
var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
|
|
@@ -87,7 +85,7 @@
|
|
|
87
85
|
* @param {String} bin binary string
|
|
88
86
|
* @returns {string} Base64-encoded string
|
|
89
87
|
*/
|
|
90
|
-
var _btoa =
|
|
88
|
+
var _btoa = typeof btoa === 'function' ? function (bin) { return btoa(bin); }
|
|
91
89
|
: _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); }
|
|
92
90
|
: btoaPolyfill;
|
|
93
91
|
var _fromUint8Array = _hasBuffer
|
|
@@ -216,7 +214,7 @@
|
|
|
216
214
|
* @param {String} asc Base64-encoded string
|
|
217
215
|
* @returns {string} binary string
|
|
218
216
|
*/
|
|
219
|
-
var _atob =
|
|
217
|
+
var _atob = typeof atob === 'function' ? function (asc) { return atob(_tidyB64(asc)); }
|
|
220
218
|
: _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
|
|
221
219
|
: atobPolyfill;
|
|
222
220
|
//
|
package/base64.mjs
CHANGED
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
11
11
|
*/
|
|
12
|
-
const version = '3.7.
|
|
12
|
+
const version = '3.7.7';
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use lowercase `version`.
|
|
15
15
|
*/
|
|
16
16
|
const VERSION = version;
|
|
17
|
-
const _hasatob = typeof atob === 'function';
|
|
18
|
-
const _hasbtoa = typeof btoa === 'function';
|
|
19
17
|
const _hasBuffer = typeof Buffer === 'function';
|
|
20
18
|
const _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
|
|
21
19
|
const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
|
|
@@ -59,7 +57,7 @@ const btoaPolyfill = (bin) => {
|
|
|
59
57
|
* @param {String} bin binary string
|
|
60
58
|
* @returns {string} Base64-encoded string
|
|
61
59
|
*/
|
|
62
|
-
const _btoa =
|
|
60
|
+
const _btoa = typeof btoa === 'function' ? (bin) => btoa(bin)
|
|
63
61
|
: _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64')
|
|
64
62
|
: btoaPolyfill;
|
|
65
63
|
const _fromUint8Array = _hasBuffer
|
|
@@ -182,7 +180,7 @@ const atobPolyfill = (asc) => {
|
|
|
182
180
|
* @param {String} asc Base64-encoded string
|
|
183
181
|
* @returns {string} binary string
|
|
184
182
|
*/
|
|
185
|
-
const _atob =
|
|
183
|
+
const _atob = typeof atob === 'function' ? (asc) => atob(_tidyB64(asc))
|
|
186
184
|
: _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
|
|
187
185
|
: atobPolyfill;
|
|
188
186
|
//
|
|
@@ -269,7 +267,7 @@ const gBase64 = {
|
|
|
269
267
|
toUint8Array: toUint8Array,
|
|
270
268
|
extendString: extendString,
|
|
271
269
|
extendUint8Array: extendUint8Array,
|
|
272
|
-
extendBuiltins: extendBuiltins
|
|
270
|
+
extendBuiltins: extendBuiltins
|
|
273
271
|
};
|
|
274
272
|
// makecjs:CUT //
|
|
275
273
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
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
|
-
|
|
2
|
+
"name": "js-base64",
|
|
3
|
+
"version": "3.7.7",
|
|
4
|
+
"description": "Yet another Base64 transcoder in pure-JS",
|
|
5
|
+
"main": "base64.js",
|
|
6
|
+
"module": "base64.mjs",
|
|
7
|
+
"types": "base64.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"base64.js",
|
|
11
|
+
"base64.mjs",
|
|
12
|
+
"base64.d.ts",
|
|
13
|
+
"base64.d.mts"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./base64.d.mts",
|
|
19
|
+
"default": "./base64.mjs"
|
|
20
|
+
},
|
|
21
|
+
"require": {
|
|
22
|
+
"types": "./base64.d.ts",
|
|
23
|
+
"default": "./base64.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "make clean && make test"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^20.11.5",
|
|
33
|
+
"mocha": "^10.2.0",
|
|
34
|
+
"typescript": "^5.3.3"
|
|
35
|
+
},
|
|
36
|
+
"repository": "git+https://github.com/dankogai/js-base64.git",
|
|
37
|
+
"keywords": [
|
|
38
|
+
"base64",
|
|
39
|
+
"binary"
|
|
40
|
+
],
|
|
41
|
+
"author": "Dan Kogai",
|
|
42
|
+
"license": "BSD-3-Clause"
|
|
38
43
|
}
|