Comparing version 3.4.0 to 3.4.1
@@ -12,7 +12,7 @@ /** | ||
*/ | ||
declare const version = "3.4.0"; | ||
declare const version = "3.4.1"; | ||
/** | ||
* @deprecated use lowercase `version`. | ||
*/ | ||
declare const VERSION = "3.4.0"; | ||
declare const VERSION = "3.4.1"; | ||
/** | ||
@@ -19,0 +19,0 @@ * does what `window.btoa` of web browsers does. |
@@ -43,3 +43,3 @@ | ||
*/ | ||
const version = '3.4.0'; | ||
const version = '3.4.1'; | ||
/** | ||
@@ -49,10 +49,2 @@ * @deprecated use lowercase `version`. | ||
const VERSION = version; | ||
const _b64chars = [ | ||
...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | ||
]; | ||
const _b64tab = ((chars) => { | ||
let tab = {}; | ||
_b64chars.forEach((c, i) => tab[c] = i); | ||
return tab; | ||
})(_b64chars); | ||
const _hasBuffer = typeof Buffer === 'function'; | ||
@@ -128,14 +120,2 @@ const _hasatob = typeof atob === 'function'; | ||
const btou = (src) => decodeURIComponent(escape(src)); | ||
const _cb_decode = (cccc) => { | ||
let len = cccc.length, padlen = len % 4, n = (len > 0 ? _b64tab[cccc.charAt(0)] << 18 : 0) | ||
| (len > 1 ? _b64tab[cccc.charAt(1)] << 12 : 0) | ||
| (len > 2 ? _b64tab[cccc.charAt(2)] << 6 : 0) | ||
| (len > 3 ? _b64tab[cccc.charAt(3)] : 0), chars = [ | ||
_fromCharCode(n >>> 16), | ||
_fromCharCode((n >>> 8) & 0xff), | ||
_fromCharCode(n & 0xff) | ||
]; | ||
chars.length -= [0, 0, 2, 1][padlen]; | ||
return chars.join(''); | ||
}; | ||
/** | ||
@@ -148,3 +128,5 @@ * does what `window.atob` of web browsers does. | ||
: _hasBuffer ? (a) => Buffer.from(a, 'base64').toString('binary') | ||
: (a) => _tidyB64(a).replace(/\S{1,4}/g, _cb_decode); | ||
: (a) => { | ||
throw ReferenceError('neither `atob` nor `Buffer` is available '); | ||
}; | ||
const _decode = _hasBuffer | ||
@@ -228,3 +210,6 @@ ? (a) => Buffer.from(a, 'base64').toString('utf8') | ||
// | ||
gBase64.Base64 = { ...gBase64 }; | ||
// ES5 is yet to have Object.assign() that may make transpilers unhappy. | ||
// gBase64.Base64 = Object.assign({}, gBase64); | ||
gBase64.Base64 = {}; | ||
Object.keys(gBase64).forEach(k => gBase64.Base64[k] = gBase64[k]); | ||
return gBase64; | ||
@@ -231,0 +216,0 @@ })); |
{ | ||
"name": "js-base64", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "Yet another Base64 transcoder in pure-JS", | ||
@@ -5,0 +5,0 @@ "main": "base64.js", |
@@ -32,3 +32,3 @@ [![build status](https://secure.travis-ci.org/dankogai/js-base64.png)](http://travis-ci.org/dankogai/js-base64) | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.4.0/base64.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.4.1/base64.min.js"></script> | ||
``` | ||
@@ -56,3 +56,3 @@ | ||
// note jsdelivr.net does not automatically minify .mjs | ||
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.4.0/base64.mjs'; | ||
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.4.1/base64.mjs'; | ||
</script> | ||
@@ -64,3 +64,3 @@ ``` | ||
// or if you prefer no Base64 namespace | ||
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.4.0/base64.mjs'; | ||
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.4.1/base64.mjs'; | ||
</script> | ||
@@ -67,0 +67,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22891
504