js-base64 3.8.0 → 3.8.1
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 +4 -3
- package/base64.d.mts +2 -2
- package/base64.d.ts +2 -2
- package/base64.js +6 -2
- package/base64.mjs +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
[](https://github.com/dankogai/js-base64/actions/workflows/node.js.yml)
|
|
2
|
+
[](https://github.com/dankogai/js-base64/actions/workflows/bun.yml)
|
|
2
3
|
|
|
3
4
|
# base64.js
|
|
4
5
|
|
|
@@ -25,7 +26,7 @@ Locally…
|
|
|
25
26
|
… or Directly from CDN. In which case you don't even need to install.
|
|
26
27
|
|
|
27
28
|
```html
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.8.
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.min.js"></script>
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
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 +49,14 @@ or even remotely.
|
|
|
48
49
|
```html
|
|
49
50
|
<script type="module">
|
|
50
51
|
// note jsdelivr.net does not automatically minify .mjs
|
|
51
|
-
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.
|
|
52
|
+
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.mjs';
|
|
52
53
|
</script>
|
|
53
54
|
```
|
|
54
55
|
|
|
55
56
|
```html
|
|
56
57
|
<script type="module">
|
|
57
58
|
// or if you prefer no Base64 namespace
|
|
58
|
-
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.
|
|
59
|
+
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.mjs';
|
|
59
60
|
</script>
|
|
60
61
|
```
|
|
61
62
|
|
package/base64.d.mts
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
11
11
|
*/
|
|
12
|
-
declare const version = "3.8.
|
|
12
|
+
declare const version = "3.8.1";
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use lowercase `version`.
|
|
15
15
|
*/
|
|
16
|
-
declare const VERSION = "3.8.
|
|
16
|
+
declare const VERSION = "3.8.1";
|
|
17
17
|
/**
|
|
18
18
|
* polyfill version of `btoa`
|
|
19
19
|
*/
|
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.8.
|
|
12
|
+
declare const version = "3.8.1";
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use lowercase `version`.
|
|
15
15
|
*/
|
|
16
|
-
declare const VERSION = "3.8.
|
|
16
|
+
declare const VERSION = "3.8.1";
|
|
17
17
|
/**
|
|
18
18
|
* polyfill version of `btoa`
|
|
19
19
|
*/
|
package/base64.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
*
|
|
38
38
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
39
39
|
*/
|
|
40
|
-
var version = '3.8.
|
|
40
|
+
var version = '3.8.1';
|
|
41
41
|
/**
|
|
42
42
|
* @deprecated use lowercase `version`.
|
|
43
43
|
*/
|
|
@@ -86,7 +86,11 @@
|
|
|
86
86
|
* @returns {string} Base64-encoded string
|
|
87
87
|
*/
|
|
88
88
|
var _btoa = typeof btoa === 'function' ? function (bin) { return btoa(bin); }
|
|
89
|
-
: _hasBuffer ? function (bin) {
|
|
89
|
+
: _hasBuffer ? function (bin) {
|
|
90
|
+
if (/[^\x00-\xff]/.test(bin))
|
|
91
|
+
throw new TypeError('invalid character found');
|
|
92
|
+
return Buffer.from(bin, 'binary').toString('base64');
|
|
93
|
+
}
|
|
90
94
|
: btoaPolyfill;
|
|
91
95
|
var _fromUint8Array = _hasBuffer
|
|
92
96
|
? function (u8a) { return Buffer.from(u8a).toString('base64'); }
|
package/base64.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @author Dan Kogai (https://github.com/dankogai)
|
|
11
11
|
*/
|
|
12
|
-
const version = '3.8.
|
|
12
|
+
const version = '3.8.1';
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use lowercase `version`.
|
|
15
15
|
*/
|
|
@@ -58,7 +58,11 @@ const btoaPolyfill = (bin) => {
|
|
|
58
58
|
* @returns {string} Base64-encoded string
|
|
59
59
|
*/
|
|
60
60
|
const _btoa = typeof btoa === 'function' ? (bin) => btoa(bin)
|
|
61
|
-
: _hasBuffer ? (bin) =>
|
|
61
|
+
: _hasBuffer ? (bin) => {
|
|
62
|
+
if (/[^\x00-\xff]/.test(bin))
|
|
63
|
+
throw new TypeError('invalid character found');
|
|
64
|
+
return Buffer.from(bin, 'binary').toString('base64');
|
|
65
|
+
}
|
|
62
66
|
: btoaPolyfill;
|
|
63
67
|
const _fromUint8Array = _hasBuffer
|
|
64
68
|
? (u8a) => Buffer.from(u8a).toString('base64')
|