diff --git a/text.js b/text.js index 0b5fef8..e1fdc68 100644 --- a/text.js +++ b/text.js @@ -46,7 +46,7 @@ Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'}); * @param {{stream: boolean}=} options * @return {!Uint8Array} */ -FastTextEncoder.prototype.encode = function(string, options={stream: false}) { +FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) { if (options.stream) { throw new Error(`Failed to encode: the 'stream' option is unsupported.`); } @@ -135,7 +135,7 @@ Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false}); * @param {{stream: boolean}=} options * @return {string} */ -FastTextDecoder.prototype.decode = function(buffer, options={stream: false}) { +FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) { if (options['stream']) { throw new Error(`Failed to decode: the 'stream' option is unsupported.`); } diff --git a/text.min.js b/text.min.js index ad6ce8f..9627738 100644 --- a/text.min.js +++ b/text.min.js @@ -1,2 +1,5 @@ -(function(b){function e(){}function c(a,d){a=void 0===a?"utf-8":a;d=void 0===d?{fatal:!1}:d;if(-1===f.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(d.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(b.TextEncoder&&b.TextDecoder)return!1;var f=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(e.prototype,"encoding",{value:"utf-8"});Object.defineProperty(c.prototype, -"encoding",{value:"utf-8"});Object.defineProperty(c.prototype,"fatal",{value:!1});Object.defineProperty(c.prototype,"ignoreBOM",{value:!1});b.TextEncoder=e;b.TextDecoder=c})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); +(function(l){function m(){}function k(c,a){c=void 0===c?"utf-8":c;a=void 0===a?{fatal:!1}:a;if(-1===n.indexOf(c.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+c+"') is invalid.");if(a.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(l.TextEncoder&&l.TextDecoder)return!1;var n=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(c, +a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");a=0;for(var g=c.length,f=0,b=Math.max(32,g+(g>>1)+7),e=new Uint8Array(b>>3<<3);a=d){if(a=d)continue}f+4>e.length&&(b+=8,b*=1+a/c.length*2,b=b>>3<<3,h=new Uint8Array(b),h.set(e),e=h);if(0===(d&4294967168))e[f++]=d;else{if(0===(d&4294965248))e[f++]= +d>>6&31|192;else if(0===(d&4294901760))e[f++]=d>>12&15|224,e[f++]=d>>6&63|128;else if(0===(d&4292870144))e[f++]=d>>18&7|240,e[f++]=d>>12&63|128,e[f++]=d>>6&63|128;else continue;e[f++]=d&63|128}}return e.slice?e.slice(0,f):e.subarray(0,f)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});k.prototype.decode=function(c,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to decode: the 'stream' option is unsupported."); +a=c;!(a instanceof Uint8Array)&&a.buffer instanceof ArrayBuffer&&(a=new Uint8Array(c.buffer));c=0;for(var g=[],f=[];;){var b=c>>10&1023|55296),b=56320|b&1023);g.push(b)}}};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); diff --git a/text.min.js.map b/text.min.js.map index efb1f7d..7d96d5d 100644 --- a/text.min.js.map +++ b/text.min.js.map @@ -1,8 +1,8 @@ { "version":3, "file":"text.min.js", -"lineCount":2, -"mappings":"AAsBC,SAAQ,CAACA,CAAD,CAAQ,CAcjBC,QAASA,EAAe,EAAG,EAgF3BC,QAASA,EAAe,CAACC,CAAD,CAAmBC,CAAnB,CAA2C,CAA1CD,CAAA,CAAA,IAAA,EAAA,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MhB,CAAA,EAAN,CAAR6B,CAAuB,EAGzBC,EAAAA;CAAcJ,CAAdI,CAAsB,CAAtBA,GAA+B,EAA/BA,CAAwCH,CAAxCG,EAAiD,EAAjDA,CAA0DF,CAA1DE,EAAmE,CAAnEA,CAA2ED,CAC/D,MAAhB,CAAIC,CAAJ,GAEEA,CAEA,EAFa,KAEb,CADAZ,CAAAG,KAAA,CAAcS,CAAd,GAA4B,EAA5B,CAAkC,IAAlC,CAA0C,KAA1C,CACA,CAAAA,CAAA,CAAY,KAAZ,CAAqBA,CAArB,CAAiC,IAJnC,CAMAZ,EAAAG,KAAA,CAAaS,CAAb,CAbkC,CAnC7B,CAnBqE,CA0EhF/C,EAAA,YAAA,CAAuBC,CACvBD,EAAA,YAAA,CAAuBE,CA9LN,CAAhB,CAAA,CAgMmB,WAAlB,GAAA,MAAO8C,OAAP,CAAgCA,MAAhC,CAA4D,WAAlB,GAAA,MAAOC,OAAP,CAAgCA,MAAhC,CAAyC,IAhMpF;", "sources":["text.js"], -"names":["scope","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","Object","defineProperty","prototype","value","window","global"] +"names":["scope","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","Object","defineProperty","prototype","value","string","stream","pos","len","length","at","tlen","Math","max","target","Uint8Array","charCodeAt","extra","update","set","slice","subarray","buffer","bytes","ArrayBuffer","pending","chunks","more","push","String","fromCharCode","apply","join","byte1","byte2","byte3","byte4","codepoint","window","global"] }