js-base64 3.5.1 → 3.5.2

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
@@ -6,9 +6,9 @@ Yet another [Base64] transcoder.
6
6
 
7
7
  [Base64]: http://en.wikipedia.org/wiki/Base64
8
8
 
9
- ## HEADS UP: switch to TypeScript since version 3.3
9
+ ## HEADS UP
10
10
 
11
- In version 3.0 `js-base64` switch to ES2015 module. That made it easy to switch to TypeScript(just renaming `base64.mjs` to `base64.ts` was almost enough). Now `base64.mjs` is compiled from `base64.ts` then `base64.js` is generated from `base64.mjs`.
11
+ In version 3.0 `js-base64` switch to ES2015 module so it is no longer compatible with legacy browsers like IE (see below). And 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`.
12
12
 
13
13
  ## Install
14
14
 
@@ -29,7 +29,7 @@ Locally…
29
29
  … or Directly from CDN. In which case you don't even need to install.
30
30
 
31
31
  ```html
32
- <script src="https://cdn.jsdelivr.net/npm/js-base64@3.5.1/base64.min.js"></script>
32
+ <script src="https://cdn.jsdelivr.net/npm/js-base64@3.5.2/base64.min.js"></script>
33
33
  ```
34
34
 
35
35
  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`.
@@ -52,14 +52,14 @@ or even remotely.
52
52
  ```html
53
53
  <script type="module">
54
54
  // note jsdelivr.net does not automatically minify .mjs
55
- import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.5.1/base64.mjs';
55
+ import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.5.2/base64.mjs';
56
56
  </script>
57
57
  ```
58
58
 
59
59
  ```html
60
60
  <script type="module">
61
61
  // or if you prefer no Base64 namespace
62
- import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.5.1/base64.mjs';
62
+ import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.5.2/base64.mjs';
63
63
  </script>
64
64
  ```
65
65
 
@@ -80,7 +80,6 @@ require=require('esm')(module);
80
80
  import {Base64} from 'js-base64';
81
81
  ```
82
82
 
83
-
84
83
  ## SYNOPSIS
85
84
 
86
85
  ```javascript
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.5.1";
12
+ declare const version = "3.5.2";
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
16
- declare const VERSION = "3.5.1";
16
+ declare const VERSION = "3.5.2";
17
17
  /**
18
18
  * polyfill version of `btoa`
19
19
  */
@@ -63,16 +63,16 @@ declare const atobPolyfill: (asc: string) => string;
63
63
  * @returns {string} binary string
64
64
  */
65
65
  declare const _atob: (asc: string) => string;
66
+ /**
67
+ * converts a Base64 string to a Uint8Array.
68
+ */
69
+ declare const toUint8Array: (a: string) => Uint8Array;
66
70
  /**
67
71
  * converts a Base64 string to a UTF-8 string.
68
72
  * @param {String} src Base64 string. Both normal and URL-safe are supported
69
73
  * @returns {string} UTF-8 string
70
74
  */
71
75
  declare const decode: (src: string) => string;
72
- /**
73
- * converts a Base64 string to a Uint8Array.
74
- */
75
- declare const toUint8Array: (a: string) => any;
76
76
  /**
77
77
  * extend String.prototype with relevant methods
78
78
  */
@@ -101,7 +101,7 @@ declare const gBase64: {
101
101
  btou: (b: string) => string;
102
102
  decode: (src: string) => string;
103
103
  fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string;
104
- toUint8Array: (a: string) => any;
104
+ toUint8Array: (a: string) => Uint8Array;
105
105
  extendString: () => void;
106
106
  extendUint8Array: () => void;
107
107
  extendBuiltins: () => void;
package/base64.js CHANGED
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * @author Dan Kogai (https://github.com/dankogai)
42
42
  */
43
- const version = '3.5.1';
43
+ const version = '3.5.2';
44
44
  /**
45
45
  * @deprecated use lowercase `version`.
46
46
  */
@@ -144,7 +144,8 @@ const utob = (u) => u.replace(re_utob, cb_utob);
144
144
  //
145
145
  const _encode = _hasBuffer
146
146
  ? (s) => Buffer.from(s, 'utf8').toString('base64')
147
- : _TE ? (s) => _fromUint8Array(_TE.encode(s))
147
+ : _TE
148
+ ? (s) => _fromUint8Array(_TE.encode(s))
148
149
  : (s) => _btoa(utob(s));
149
150
  /**
150
151
  * converts a UTF-8-encoded string to a Base64 string.
@@ -216,6 +217,15 @@ const atobPolyfill = (asc) => {
216
217
  const _atob = _hasatob ? (asc) => atob(_tidyB64(asc))
217
218
  : _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
218
219
  : atobPolyfill;
220
+ //
221
+ const _toUint8Array = _hasBuffer
222
+ ? (a) => _U8Afrom(Buffer.from(a, 'base64'))
223
+ : (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
224
+ /**
225
+ * converts a Base64 string to a Uint8Array.
226
+ */
227
+ const toUint8Array = (a) => _toUint8Array(_unURI(a));
228
+ //
219
229
  const _decode = _hasBuffer
220
230
  ? (a) => Buffer.from(a, 'base64').toString('utf8')
221
231
  : _TD
@@ -229,14 +239,6 @@ const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/')
229
239
  */
230
240
  const decode = (src) => _decode(_unURI(src));
231
241
  //
232
- const _toUint8Array = _hasBuffer
233
- ? (a) => _U8Afrom(Buffer.from(a, 'base64'))
234
- : (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
235
- /**
236
- * converts a Base64 string to a Uint8Array.
237
- */
238
- const toUint8Array = (a) => _toUint8Array(_unURI(a));
239
- //
240
242
  const _noEnum = (v) => {
241
243
  return {
242
244
  value: v, enumerable: false, writable: true, configurable: true
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.5.1';
12
+ const version = '3.5.2';
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
@@ -113,7 +113,8 @@ const utob = (u) => u.replace(re_utob, cb_utob);
113
113
  //
114
114
  const _encode = _hasBuffer
115
115
  ? (s) => Buffer.from(s, 'utf8').toString('base64')
116
- : _TE ? (s) => _fromUint8Array(_TE.encode(s))
116
+ : _TE
117
+ ? (s) => _fromUint8Array(_TE.encode(s))
117
118
  : (s) => _btoa(utob(s));
118
119
  /**
119
120
  * converts a UTF-8-encoded string to a Base64 string.
@@ -185,6 +186,15 @@ const atobPolyfill = (asc) => {
185
186
  const _atob = _hasatob ? (asc) => atob(_tidyB64(asc))
186
187
  : _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
187
188
  : atobPolyfill;
189
+ //
190
+ const _toUint8Array = _hasBuffer
191
+ ? (a) => _U8Afrom(Buffer.from(a, 'base64'))
192
+ : (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
193
+ /**
194
+ * converts a Base64 string to a Uint8Array.
195
+ */
196
+ const toUint8Array = (a) => _toUint8Array(_unURI(a));
197
+ //
188
198
  const _decode = _hasBuffer
189
199
  ? (a) => Buffer.from(a, 'base64').toString('utf8')
190
200
  : _TD
@@ -198,14 +208,6 @@ const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/')
198
208
  */
199
209
  const decode = (src) => _decode(_unURI(src));
200
210
  //
201
- const _toUint8Array = _hasBuffer
202
- ? (a) => _U8Afrom(Buffer.from(a, 'base64'))
203
- : (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
204
- /**
205
- * converts a Base64 string to a Uint8Array.
206
- */
207
- const toUint8Array = (a) => _toUint8Array(_unURI(a));
208
- //
209
211
  const _noEnum = (v) => {
210
212
  return {
211
213
  value: v, enumerable: false, writable: true, configurable: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-base64",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "description": "Yet another Base64 transcoder in pure-JS",
5
5
  "main": "base64.js",
6
6
  "module": "base64.mjs",