1 2 3// 4// THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND! 5// 6;(function(global, factory) { 7 typeof exports === 'object' && typeof module !== 'undefined' 8 ? module.exports = factory() 9 : typeof define === 'function' && define.amd 10 ? define(factory) : 11 // cf. https://github.com/dankogai/js-base64/issues/119 12 (function() { 13 // existing version for noConflict() 14 const _Base64 = global.Base64; 15 const gBase64 = factory(); 16 gBase64.noConflict = () => { 17 global.Base64 = _Base64; 18 return gBase64; 19 }; 20 if (global.Meteor) { // Meteor.js 21 Base64 = gBase64; 22 } 23 global.Base64 = gBase64; 24 })(); 25}((typeof self !== 'undefined' ? self 26 : typeof window !== 'undefined' ? window 27 : typeof global !== 'undefined' ? global 28 : this 29), function() { 30 'use strict'; 31 32/** 33 * base64.ts 34 * 35 * Licensed under the BSD 3-Clause License. 36 * http://opensource.org/licenses/BSD-3-Clause 37 * 38 * References: 39 * http://en.wikipedia.org/wiki/Base64 40 * 41 * @author Dan Kogai (https://github.com/dankogai) 42 */ 43const version = '3.5.2'; 44/** 45 * @deprecated use lowercase `version`. 46 */ 47const VERSION = version; 48const _hasatob = typeof atob === 'function'; 49const _hasbtoa = typeof btoa === 'function'; 50const _hasBuffer = typeof Buffer === 'function'; 51const _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined; 52const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined; 53const b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 54const b64chs = [...b64ch]; 55const b64tab = ((a) => { 56 let tab = {}; 57 a.forEach((c, i) => tab[c] = i); 58 return tab; 59})(b64chs); 60const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; 61const _fromCC = String.fromCharCode.bind(String); 62const _U8Afrom = typeof Uint8Array.from === 'function' 63 ? Uint8Array.from.bind(Uint8Array) 64 : (it, fn = (x) => x) => new Uint8Array(Array.prototype.slice.call(it, 0).map(fn)); 65const _mkUriSafe = (src) => src 66 .replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_') 67 .replace(/=+$/m, ''); 68const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, ''); 69/** 70 * polyfill version of `btoa` 71 */ 72const btoaPolyfill = (bin) => { 73 // console.log('polyfilled'); 74 let u32, c0, c1, c2, asc = ''; 75 const pad = bin.length % 3; 76 for (let i = 0; i < bin.length;) { 77 if ((c0 = bin.charCodeAt(i++)) > 255 || 78 (c1 = bin.charCodeAt(i++)) > 255 || 79 (c2 = bin.charCodeAt(i++)) > 255) 80 throw new TypeError('invalid character found'); 81 u32 = (c0 << 16) | (c1 << 8) | c2; 82 asc += b64chs[u32 >> 18 & 63] 83 + b64chs[u32 >> 12 & 63] 84 + b64chs[u32 >> 6 & 63] 85 + b64chs[u32 & 63]; 86 } 87 return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc; 88}; 89/** 90 * does what `window.btoa` of web browsers do. 91 * @param {String} bin binary string 92 * @returns {string} Base64-encoded string 93 */ 94const _btoa = _hasbtoa ? (bin) => btoa(bin) 95 : _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64') 96 : btoaPolyfill; 97const _fromUint8Array = _hasBuffer 98 ? (u8a) => Buffer.from(u8a).toString('base64') 99 : (u8a) => { 100 // cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326 101 const maxargs = 0x1000; 102 let strs = []; 103 for (let i = 0, l = u8a.length; i < l; i += maxargs) { 104 strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs))); 105 } 106 return _btoa(strs.join('')); 107 }; 108/** 109 * converts a Uint8Array to a Base64 string. 110 * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5 111 * @returns {string} Base64 string 112 */ 113const fromUint8Array = (u8a, urlsafe = false) => urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a); 114// This trick is found broken https://github.com/dankogai/js-base64/issues/130 115// const utob = (src: string) => unescape(encodeURIComponent(src)); 116// reverting good old fationed regexp 117const cb_utob = (c) => { 118 if (c.length < 2) {
119 var cc = c.charCodeAt(0); 120 return cc < 0x80 ? c 121 : cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6)) 122 + _fromCC(0x80 | (cc & 0x3f))) 123 : (_fromCC(0xe0 | ((cc >>> 12) & 0x0f)) 124 + _fromCC(0x80 | ((cc >>> 6) & 0x3f)) 125 + _fromCC(0x80 | (cc & 0x3f))); 126 } 127 else { 128 var cc = 0x10000 129 + (c.charCodeAt(0) - 0xD800) * 0x400 130 + (c.charCodeAt(1) - 0xDC00); 131 return (_fromCC(0xf0 | ((cc >>> 18) & 0x07)) 132 + _fromCC(0x80 | ((cc >>> 12) & 0x3f)) 133 + _fromCC(0x80 | ((cc >>> 6) & 0x3f)) 134 + _fromCC(0x80 | (cc & 0x3f))); 135 } 136}; 137const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; 138/** 139 * @deprecated should have been internal use only. 140 * @param {string} src UTF-8 string 141 * @returns {string} UTF-16 string 142 */ 143const utob = (u) => u.replace(re_utob, cb_utob); 144// 145const _encode = _hasBuffer 146 ? (s) => Buffer.from(s, 'utf8').toString('base64') 147 : _TE 148 ? (s) => _fromUint8Array(_TE.encode(s)) 149 : (s) => _btoa(utob(s)); 150/** 151 * converts a UTF-8-encoded string to a Base64 string. 152 * @param {boolean} [urlsafe] if `true` make the result URL-safe 153 * @returns {string} Base64 string 154 */ 155const encode = (src, urlsafe = false) => urlsafe 156 ? _mkUriSafe(_encode(src)) 157 : _encode(src); 158/** 159 * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5. 160 * @returns {string} Base64 string 161 */ 162const encodeURI = (src) => encode(src, true); 163// This trick is found broken https://github.com/dankogai/js-base64/issues/130 164// const btou = (src: string) => decodeURIComponent(escape(src)); 165// reverting good old fationed regexp 166const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g; 167const cb_btou = (cccc) => { 168 switch (cccc.length) { 169 case 4: 170 var cp = ((0x07 & cccc.charCodeAt(0)) << 18) 171 | ((0x3f & cccc.charCodeAt(1)) << 12) 172 | ((0x3f & cccc.charCodeAt(2)) << 6) 173 | (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000; 174 return (_fromCC((offset >>> 10) + 0xD800) 175 + _fromCC((offset & 0x3FF) + 0xDC00)); 176 case 3: 177 return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12) 178 | ((0x3f & cccc.charCodeAt(1)) << 6) 179 | (0x3f & cccc.charCodeAt(2))); 180 default: 181 return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6) 182 | (0x3f & cccc.charCodeAt(1))); 183 } 184}; 185/** 186 * @deprecated should have been internal use only. 187 * @param {string} src UTF-16 string 188 * @returns {string} UTF-8 string 189 */ 190const btou = (b) => b.replace(re_btou, cb_btou); 191/** 192 * polyfill version of `atob` 193 */ 194const atobPolyfill = (asc) => { 195 // console.log('polyfilled'); 196 asc = asc.replace(/\s+/g, ''); 197 if (!b64re.test(asc)) 198 throw new TypeError('malformed base64.'); 199 asc += '=='.slice(2 - (asc.length & 3)); 200 let u24, bin = '', r1, r2; 201 for (let i = 0; i < asc.length;) { 202 u24 = b64tab[asc.charAt(i++)] << 18 203 | b64tab[asc.charAt(i++)] << 12 204 | (r1 = b64tab[asc.charAt(i++)]) << 6 205 | (r2 = b64tab[asc.charAt(i++)]); 206 bin += r1 === 64 ? _fromCC(u24 >> 16 & 255) 207 : r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255) 208 : _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255); 209 } 210 return bin; 211}; 212/** 213 * does what `window.atob` of web browsers do. 214 * @param {String} asc Base64-encoded string 215 * @returns {string} binary string 216 */ 217const _atob = _hasatob ? (asc) => atob(_tidyB64(asc)) 218 : _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary') 219 : atobPolyfill; 220// 221const _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 */ 227const toUint8Array = (a) => _toUint8Array(_unURI(a)); 228// 229const _decode = _hasBuffer 230 ? (a) => Buffer.from(a, 'base64').toString('utf8') 231 : _TD 232 ? (a) => _TD.decode(_toUint8Array(a)) 233 : (a) => btou(_atob(a)); 234const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/')); 235/** 236 * converts a Base64 string to a UTF-8 string. 237 * @param {String} src Base64 string. Both normal and URL-safe are supported 238 * @returns {string} UTF-8 string 239 */ 240const decode = (src) => _decode(_unURI(src)); 241// 242const _noEnum = (v) => { 243 return { 244 value: v, enumerable: false, writable: true, configurable: true 245 }; 246}; 247/** 248 * extend String.prototype with relevant methods 249 */ 250const extendString = function () { 251 const _add = (name, body) => Object.defineProperty(String.prototype, name, _noEnum(body)); 252 _add('fromBase64', function () { return decode(this); }); 253 _add('toBase64', function (urlsafe) { return encode(this, urlsafe); }); 254 _add('toBase64URI', function () { return encode(this, true); }); 255 _add('toBase64URL', function () { return encode(this, true); }); 256 _add('toUint8Array', function () { return toUint8Array(this); }); 257}; 258/** 259 * extend Uint8Array.prototype with relevant methods 260 */ 261const extendUint8Array = function () { 262 const _add = (name, body) => Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); 263 _add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); }); 264 _add('toBase64URI', function () { return fromUint8Array(this, true); }); 265 _add('toBase64URL', function () { return fromUint8Array(this, true); }); 266}; 267/** 268 * extend Builtin prototypes with relevant methods 269 */ 270const extendBuiltins = () => { 271 extendString(); 272 extendUint8Array(); 273}; 274const gBase64 = { 275 version: version, 276 VERSION: VERSION, 277 atob: _atob, 278 atobPolyfill: atobPolyfill, 279 btoa: _btoa, 280 btoaPolyfill: btoaPolyfill, 281 fromBase64: decode, 282 toBase64: encode, 283 encode: encode, 284 encodeURI: encodeURI, 285 encodeURL: encodeURI, 286 utob: utob, 287 btou: btou, 288 decode: decode, 289 fromUint8Array: fromUint8Array, 290 toUint8Array: toUint8Array, 291 extendString: extendString, 292 extendUint8Array: extendUint8Array, 293 extendBuiltins: extendBuiltins, 294}; 295 296 // 297 // export Base64 to the namespace 298 // 299 // ES5 is yet to have Object.assign() that may make transpilers unhappy. 300 // gBase64.Base64 = Object.assign({}, gBase64); 301 gBase64.Base64 = {};
302 Object.keys(gBase64).forEach(k => gBase64.Base64[k] = gBase64[k]); 303 return gBase64; 304})); 305 306
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.