js-base64 3.7.4 → 3.7.6

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
@@ -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.4/base64.min.js"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/js-base64@3.7.6/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.4/base64.mjs';
51
+ import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.6/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.4/base64.mjs';
58
+ import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.6/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.6";
13
+ /**
14
+ * @deprecated use lowercase `version`.
15
+ */
16
+ declare const VERSION = "3.7.6";
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.4";
12
+ declare const version = "3.7.6";
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
16
- declare const VERSION = "3.7.4";
16
+ declare const VERSION = "3.7.6";
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.4';
40
+ var version = '3.7.6';
41
41
  /**
42
42
  * @deprecated use lowercase `version`.
43
43
  */
@@ -58,10 +58,7 @@
58
58
  var _fromCC = String.fromCharCode.bind(String);
59
59
  var _U8Afrom = typeof Uint8Array.from === 'function'
60
60
  ? Uint8Array.from.bind(Uint8Array)
61
- : function (it, fn) {
62
- if (fn === void 0) { fn = function (x) { return x; }; }
63
- return new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
64
- };
61
+ : function (it) { return new Uint8Array(Array.prototype.slice.call(it, 0)); };
65
62
  var _mkUriSafe = function (src) { return src
66
63
  .replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
67
64
  var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
@@ -225,7 +222,7 @@
225
222
  //
226
223
  var _toUint8Array = _hasBuffer
227
224
  ? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
228
- : function (a) { return _U8Afrom(_atob(a), function (c) { return c.charCodeAt(0); }); };
225
+ : function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); };
229
226
  /**
230
227
  * converts a Base64 string to a Uint8Array.
231
228
  */
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.4';
12
+ const version = '3.7.6';
13
13
  /**
14
14
  * @deprecated use lowercase `version`.
15
15
  */
@@ -30,7 +30,7 @@ const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3
30
30
  const _fromCC = String.fromCharCode.bind(String);
31
31
  const _U8Afrom = typeof Uint8Array.from === 'function'
32
32
  ? Uint8Array.from.bind(Uint8Array)
33
- : (it, fn = (x) => x) => new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
33
+ : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
34
34
  const _mkUriSafe = (src) => src
35
35
  .replace(/=/g, '').replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_');
36
36
  const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, '');
@@ -188,7 +188,7 @@ const _atob = _hasatob ? (asc) => atob(_tidyB64(asc))
188
188
  //
189
189
  const _toUint8Array = _hasBuffer
190
190
  ? (a) => _U8Afrom(Buffer.from(a, 'base64'))
191
- : (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
191
+ : (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0)));
192
192
  /**
193
193
  * converts a Base64 string to a Uint8Array.
194
194
  */
@@ -269,7 +269,7 @@ const gBase64 = {
269
269
  toUint8Array: toUint8Array,
270
270
  extendString: extendString,
271
271
  extendUint8Array: extendUint8Array,
272
- extendBuiltins: extendBuiltins,
272
+ extendBuiltins: extendBuiltins
273
273
  };
274
274
  // makecjs:CUT //
275
275
  export { version };
package/package.json CHANGED
@@ -1,38 +1,43 @@
1
1
  {
2
- "name": "js-base64",
3
- "version": "3.7.4",
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
- ],
14
- "exports": {
15
- ".": {
16
- "types": "./base64.d.ts",
17
- "import": "./base64.mjs",
18
- "require": "./base64.js"
19
- },
20
- "./package.json": "./package.json"
21
- },
22
- "scripts": {
23
- "test": "make clean && make test"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^14.0.26",
27
- "esm": "^3.2.25",
28
- "mocha": "^8.4.0",
29
- "typescript": "^3.9.7"
30
- },
31
- "repository": "git+https://github.com/dankogai/js-base64.git",
32
- "keywords": [
33
- "base64",
34
- "binary"
35
- ],
36
- "author": "Dan Kogai",
37
- "license": "BSD-3-Clause"
2
+ "name": "js-base64",
3
+ "version": "3.7.6",
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
  }