forked from cryptocoinjs/base-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.min.js
2 lines (2 loc) · 994 Bytes
/
index.min.js
1
2
function k(g){function n(a){if("string"!==typeof a)throw new TypeError("Expected String");if(0===a.length)return new Uint8Array(0);for(var d=[0],c=0;c<a.length;c++){var b=l[a[c]];if(void 0===b)return;for(var e=0;e<d.length;++e)b+=d[e]*f,d[e]=b&255,b>>=8;for(;0<b;)d.push(b&255),b>>=8}for(c=0;a[c]===p&&c<a.length-1;++c)d.push(0);return Uint8Array.from(d.reverse())}for(var l={},f=g.length,p=g.charAt(0),h=0;h<g.length;h++){var m=g.charAt(h);if(void 0!==l[m])throw new TypeError(m+" is ambiguous");l[m]=
h}return{encode:function(a){if(0===a.length)return"";for(var d=[0],c=0;c<a.length;++c){for(var b=0,e=a[c];b<d.length;++b)e+=d[b]<<8,d[b]=e%f,e=e/f|0;for(;0<e;)d.push(e%f),e=e/f|0}c="";for(b=0;0===a[b]&&b<a.length-1;++b)c+=p;for(a=d.length-1;0<=a;--a)c+=g[d[a]];return c},decodeUnsafe:n,decode:function(a){if(a=n(a))return a;throw Error("Non-base"+f+" character");}}}"function"===typeof define&&define.amd?define(function(){return k}):"object"===typeof exports?module.exports=k:this.base_x=k;