UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

2 lines (1 loc) 1.65 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="function"==typeof btoa,t="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;const r="function"==typeof TextEncoder?new TextEncoder:void 0,o=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");(e=>{let t={};o.forEach(((e,r)=>t[e]=r))})();const n=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);const a=e=>{let t,r,n,a,c="";const f=e.length%3;for(let i=0;i<e.length;){if((r=e.charCodeAt(i++))>255||(n=e.charCodeAt(i++))>255||(a=e.charCodeAt(i++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|a,c+=o[t>>18&63]+o[t>>12&63]+o[t>>6&63]+o[63&t]}return f?c.slice(0,f-3)+"===".substring(f):c},c=e?e=>btoa(e):t?e=>Buffer.from(e,"binary").toString("base64"):a,f=t?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,o=e.length;r<o;r+=4096)t.push(n.apply(null,e.subarray(r,r+4096)));return c(t.join(""))},i=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?n(192|t>>>6)+n(128|63&t):n(224|t>>>12&15)+n(128|t>>>6&63)+n(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return n(240|t>>>18&7)+n(128|t>>>12&63)+n(128|t>>>6&63)+n(128|63&t)},u=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,l=e=>e.replace(u,i),s=t?e=>Buffer.from(e,"utf8").toString("base64"):r?e=>f(r.encode(e)):e=>c(l(e)),d=(e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(s(e)):s(e);exports.btoa=c,exports.btoaPolyfill=a,exports.encode=d,exports.toBase64=d,exports.utob=l;