js-base64 3.7.1 → 3.7.3

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 CHANGED
@@ -1,4 +1,4 @@
1
- [![build status](https://app.travis-ci.com/dankogai/js-base64.svg)](https://app.travis-ci.com/github/dankogai/js-base64)
1
+ [![CI via GitHub Actions](https://github.com/dankogai/js-base64/actions/workflows/node.js.yml/badge.svg)](https://github.com/dankogai/js-base64/actions/workflows/node.js.yml)
2
2
 
3
3
  # base64.js
4
4
 
@@ -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.1/base64.min.js"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/js-base64@3.7.3/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.1/base64.mjs';
51
+ import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.3/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.1/base64.mjs';
58
+ import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.3/base64.mjs';
59
59
  </script>
60
60
  ```
61
61
 
@@ -83,8 +83,8 @@ let latin = 'dankogai';
83
83
  let utf8 = '小飼弾'
84
84
  let u8s = new Uint8Array([100,97,110,107,111,103,97,105]);
85
85
  Base64.encode(latin); // ZGFua29nYWk=
86
- Base64.encode(latin, true)); // ZGFua29nYWk skips padding
87
- Base64.encodeURI(latin)); // ZGFua29nYWk
86
+ Base64.encode(latin, true); // ZGFua29nYWk skips padding
87
+ Base64.encodeURI(latin); // ZGFua29nYWk
88
88
  Base64.btoa(latin); // ZGFua29nYWk=
89
89
  Base64.btoa(utf8); // raises exception
90
90
  Base64.fromUint8Array(u8s); // ZGFua29nYWk=
@@ -162,16 +162,8 @@ Which is a Base64-encoded 1x1 transparent PNG, **DO NOT USE** `Base64.decode(png
162
162
 
163
163
  Or even better, `Base64.toUint8Array(pngBase64)`.
164
164
 
165
- ### If you really, really need an ES5 version
166
-
167
- You can transpiles to an ES5 that runs on IEs before 11. Do the following in your shell.
168
-
169
- ```shell
170
- $ make base64.es5.js
171
- ```
172
-
173
165
  ## Brief History
174
166
 
175
167
  * Since version 3.3 it is written in TypeScript. Now `base64.mjs` is compiled from `base64.ts` then `base64.js` is generated from `base64.mjs`.
176
- * Since version 3.7 `base64.js` is ES5-compatible again (hence IE11-compabile).
168
+ * Since version 3.7 `base64.js` is ES5-compatible again (hence IE11-compatible).
177
169
  * Since 3.0 `js-base64` switch to ES2015 module so it is no longer compatible with legacy browsers like IE (see above)
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.1";
12
+ declare const version = "3.7.3";
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
16
- declare const VERSION = "3.7.1";
16
+ declare const VERSION = "3.7.3";
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.7.1';
40
+ var version = '3.7.3';
41
41
  /**
42
42
  * @deprecated use lowercase `version`.
43
43
  */
@@ -63,8 +63,7 @@
63
63
  return new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
64
64
  };
65
65
  var _mkUriSafe = function (src) { return src
66
- .replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; })
67
- .replace(/=+$/m, ''); };
66
+ .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
68
67
  var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
69
68
  /**
70
69
  * polyfill version of `btoa`
@@ -251,7 +250,7 @@
251
250
  var isValid = function (src) {
252
251
  if (typeof src !== 'string')
253
252
  return false;
254
- var s = src.replace(/\s+/g, '').replace(/=+$/, '');
253
+ var s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
255
254
  return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
256
255
  };
257
256
  //
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.7.1';
12
+ const version = '3.7.3';
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
@@ -32,8 +32,7 @@ const _U8Afrom = typeof Uint8Array.from === 'function'
32
32
  ? Uint8Array.from.bind(Uint8Array)
33
33
  : (it, fn = (x) => x) => new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
34
34
  const _mkUriSafe = (src) => src
35
- .replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_')
36
- .replace(/=+$/m, '');
35
+ .replace(/=/g, '').replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_');
37
36
  const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, '');
38
37
  /**
39
38
  * polyfill version of `btoa`
@@ -214,7 +213,7 @@ const decode = (src) => _decode(_unURI(src));
214
213
  const isValid = (src) => {
215
214
  if (typeof src !== 'string')
216
215
  return false;
217
- const s = src.replace(/\s+/g, '').replace(/=+$/, '');
216
+ const s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
218
217
  return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
219
218
  };
220
219
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-base64",
3
- "version": "3.7.1",
3
+ "version": "3.7.3",
4
4
  "description": "Yet another Base64 transcoder in pure-JS",
5
5
  "main": "base64.js",
6
6
  "module": "base64.mjs",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "exports": {
14
14
  ".": {
15
+ "types": "./base64.d.ts",
15
16
  "import": "./base64.mjs",
16
17
  "require": "./base64.js"
17
18
  },