From 320a34dff998256fb43ed2cb18a4388be682e27a Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Tue, 28 Apr 2020 15:27:15 +1000 Subject: [PATCH] support Buffer for Node v5+ --- README.md | 2 ++ compile.sh | 3 +- externs.js | 20 ++++++++++++ text.js | 82 +++++++++++++++++++++++++++++++++++++++---------- text.min.js | 10 +++--- text.min.js.map | 4 +-- 6 files changed, 97 insertions(+), 24 deletions(-) create mode 100644 externs.js diff --git a/README.md b/README.md index 411fbad..84f0ffc 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ const buffer = new TextEncoder().encode('Turn me into UTF-8!'); // buffer is now a Uint8Array of [84, 117, 114, 110, ...] ``` +In Node v5.1 and above, this polyfill uses `Buffer` to implement `TextDecoder`. + # Release Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home). diff --git a/compile.sh b/compile.sh index 4f81758..b8d83ef 100755 --- a/compile.sh +++ b/compile.sh @@ -1,9 +1,10 @@ #!/usr/bin/env sh -google-closure-compiler \ +google-closure-compiler \ --compilation_level ADVANCED \ --js_output_file text.min.js \ --language_out ECMASCRIPT5 \ --warning_level VERBOSE \ --create_source_map %outname%.map \ + --externs externs.js \ text.js diff --git a/externs.js b/externs.js new file mode 100644 index 0000000..acf27c5 --- /dev/null +++ b/externs.js @@ -0,0 +1,20 @@ + +/** + * @constructor + */ +var Buffer; + +/** + * @param {!ArrayBuffer} raw + * @param {number} byteOffset + * @param {number} byteLength + * @return {!Buffer} + */ +Buffer.from = function(raw, byteOffset, byteLength) {}; + +/** + * @this {*} + * @param {string} encoding + * @return {string} + */ +Buffer.prototype.toString = function(encoding) {}; diff --git a/text.js b/text.js index d927c1d..e93cf6d 100644 --- a/text.js +++ b/text.js @@ -89,7 +89,7 @@ FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) target[at++] = value; // ASCII continue; } else if ((value & 0xfffff800) === 0) { // 2-byte - target[at++] = ((value >>> 6) & 0x1f) | 0xc0; + target[at++] = ((value >>> 6) & 0x1f) | 0xc0; } else if ((value & 0xffff0000) === 0) { // 3-byte target[at++] = ((value >>> 12) & 0x0f) | 0xe0; target[at++] = ((value >>> 6) & 0x3f) | 0x80; @@ -131,32 +131,46 @@ Object.defineProperty(FastTextDecoder.prototype, 'fatal', {value: false}); Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false}); /** - * @param {(!ArrayBuffer|!ArrayBufferView)} buffer - * @param {{stream: boolean}=} options + * @param {!Uint8Array} bytes * @return {string} */ -FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) { - if (options['stream']) { - throw new Error(`Failed to decode: the 'stream' option is unsupported.`); +function decodeBuffer(bytes) { + return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('utf-8'); +} + +/** + * @param {!Uint8Array} bytes + * @return {string} + */ +function decodeSyncXHR(bytes) { + const b = new Blob([bytes]); + const u = URL.createObjectURL(b); + + try { + const x = new XMLHttpRequest(); + x.open('GET', u, false); + x.send(null); + return x.responseText; + } catch (e) { + return decodeFallback(bytes); + } finally { + URL.revokeObjectURL(u); } +} - // Accept Uint8Array instances as-is. - let bytes = buffer; +/** + * @param {!Uint8Array} bytes + * @return {string} + */ +function decodeFallback(bytes) { let inputIndex = 0; - // Look for ArrayBufferView, which isn't a real type, but basically represents - // all the valid TypedArray types plus DataView. They all have ".buffer" as - // an instance of ArrayBuffer. - if (!(bytes instanceof Uint8Array) && bytes.buffer instanceof ArrayBuffer) { - bytes = new Uint8Array(buffer.buffer); - } - // Create a working buffer for UTF-16 code points, but don't generate one // which is too large for small input sizes. UTF-8 to UCS-16 conversion is // going to be at most 1:1, if all code points are ASCII. The other extreme // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50% // fewer entries in the output. - const pendingSize = Math.min(256 * 256, buffer.length + 1); + const pendingSize = Math.min(256 * 256, bytes.length + 1); const pending = new Uint16Array(pendingSize); const chunks = []; let pendingIndex = 0; @@ -217,6 +231,42 @@ FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) } } +// Decoding a string is pretty slow, but use alternative options where possible. +let decodeImpl = decodeFallback; +if (typeof Buffer === 'function' && Buffer.from) { + // Buffer.from was added in Node v5.10.0 (2015-11-17). + decodeImpl = decodeBuffer; +} else if (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function') { + // Blob and URL.createObjectURL are available from IE10, Safari 6, Chrome 19 + // (all released in 2012), Firefox 19 (2013), ... + + // TODO(samthor): I should probably check that this hack works in IE10 before shipping it. + // decodeImpl = decodeXHR; +} + +/** + * @param {(!ArrayBuffer|!ArrayBufferView)} buffer + * @param {{stream: boolean}=} options + * @return {string} + */ +FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) { + if (options['stream']) { + throw new Error(`Failed to decode: the 'stream' option is unsupported.`); + } + + // Accept Uint8Array instances as-is. + let bytes = buffer; + + // Look for ArrayBufferView, which isn't a real type, but basically represents + // all the valid TypedArray types plus DataView. They all have ".buffer" as + // an instance of ArrayBuffer. + if (!(bytes instanceof Uint8Array) && bytes.buffer instanceof ArrayBuffer) { + bytes = new Uint8Array(buffer.buffer); + } + + return decodeImpl(/** @type {!Uint8Array} */ (bytes)); +} + scope['TextEncoder'] = FastTextEncoder; scope['TextDecoder'] = FastTextDecoder; diff --git a/text.min.js b/text.min.js index 0cda2f2..786dd79 100644 --- a/text.min.js +++ b/text.min.js @@ -1,5 +1,5 @@ -(function(l){function m(){}function k(e,b){e=void 0===e?"utf-8":e;b=void 0===b?{fatal:!1}:b;if(-1===p.indexOf(e.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+e+"') is invalid.");if(b.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(l.TextEncoder&&l.TextDecoder)return!1;var p=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(e, -b){b=void 0===b?{stream:!1}:b;if(b.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");b=0;for(var f=e.length,d=0,h=Math.max(32,f+(f>>>1)+7),c=new Uint8Array(h>>>3<<3);b=a){if(b=a)continue}d+4>c.length&&(h+=8,h*=1+b/e.length*2,h=h>>>3<<3,g=new Uint8Array(h),g.set(c),c=g);if(0===(a&4294967168))c[d++]=a;else{if(0===(a&4294965248))c[d++]= -a>>>6&31|192;else if(0===(a&4294901760))c[d++]=a>>>12&15|224,c[d++]=a>>>6&63|128;else if(0===(a&4292870144))c[d++]=a>>>18&7|240,c[d++]=a>>>12&63|128,c[d++]=a>>>6&63|128;else continue;c[d++]=a&63|128}}return c.slice?c.slice(0,d):c.subarray(0,d)};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(e,b){b=void 0===b?{stream:!1}:b;if(b.stream)throw Error("Failed to decode: the 'stream' option is unsupported."); -b=e;var f=0;!(b instanceof Uint8Array)&&b.buffer instanceof ArrayBuffer&&(b=new Uint8Array(e.buffer));e=Math.min(65536,e.length+1);for(var d=new Uint16Array(e),h=[],c=0;;){var a=f=e-1){h.push(String.fromCharCode.apply(null,d.subarray(0,c)));if(!a)return h.join("");b=b.subarray(f);c=f=0}a=b[f++];if(0===(a&128))d[c++]=a;else if(192===(a&224)){var g=b[f++]&63;d[c++]=(a&31)<<6|g}else if(224===(a&240)){g=b[f++]&63;var n=b[f++]&63;d[c++]=(a&31)<<12|g<<6|n}else if(240===(a&248)){g=b[f++]& -63;n=b[f++]&63;var q=b[f++]&63;a=(a&7)<<18|g<<12|n<<6|q;65535>>10&1023|55296,a=56320|a&1023);d[c++]=a}}};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this); +(function(l){function p(c){for(var a=0,h=Math.min(65536,c.length+1),e=new Uint16Array(h),g=[],d=0;;){var b=a=h-1){g.push(String.fromCharCode.apply(null,e.subarray(0,d)));if(!b)return g.join("");c=c.subarray(a);d=a=0}b=c[a++];if(0===(b&128))e[d++]=b;else if(192===(b&224)){var f=c[a++]&63;e[d++]=(b&31)<<6|f}else if(224===(b&240)){f=c[a++]&63;var m=c[a++]&63;e[d++]=(b&31)<<12|f<<6|m}else if(240===(b&248)){f=c[a++]&63;m=c[a++]&63;var q=c[a++]&63;b=(b&7)<<18|f<<12|m<<6|q;65535>>10&1023|55296,b=56320|b&1023);e[d++]=b}}}function n(){}function k(c,a){c=void 0===c?"utf-8":c;a=void 0===a?{fatal:!1}:a;if(-1===r.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.");}function t(c){return Buffer.from(c.buffer,c.byteOffset,c.byteLength).toString("utf-8")}if(l.TextEncoder&&l.TextDecoder)return!1; +var r=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(n.prototype,"encoding",{value:"utf-8"});n.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 h=c.length,e=0,g=Math.max(32,h+(h>>>1)+7),d=new Uint8Array(g>>>3<<3);a=b){if(a=b)continue}e+4> +d.length&&(g+=8,g*=1+a/c.length*2,g=g>>>3<<3,f=new Uint8Array(g),f.set(d),d=f);if(0===(b&4294967168))d[e++]=b;else{if(0===(b&4294965248))d[e++]=b>>>6&31|192;else if(0===(b&4294901760))d[e++]=b>>>12&15|224,d[e++]=b>>>6&63|128;else if(0===(b&4292870144))d[e++]=b>>>18&7|240,d[e++]=b>>>12&63|128,d[e++]=b>>>6&63|128;else continue;d[e++]=b&63|128}}return d.slice?d.slice(0,e):d.subarray(0,e)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1}); +Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});"function"===typeof Buffer&&Buffer.from&&(p=t);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));return p(a)};l.TextEncoder=n;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 7e8e5e9..cdb39dc 100644 --- a/text.min.js.map +++ b/text.min.js.map @@ -2,7 +2,7 @@ "version":3, "file":"text.min.js", "lineCount":5, -"mappings":"AAsBC,SAAQ,CAACA,CAAD,CAAQ,CAcjBC,QAASA,EAAe,EAAG,EAgF3BC,QAASA,EAAe,CAACC,CAAD,CAAmBC,CAAnB,CAA2C,CAA1CD,CAAA,CAAA,IAAA,EAAA,GAAAA,CAAA,CAAS,OAAT,CAAAA,CAAkBC,EAAA,CAAA,IAAA,EAAA,GAAAA,CAAA,CAAQ,CAACC,MAAO,CAAA,CAAR,CAAR,CAAAD,CACzC,IAAuD,EAAvD,GAAIE,CAAAC,QAAA,CAAuBJ,CAAAK,YAAA,EAAvB,CAAJ,CACE,KAAM,KAAIC,UAAJ,CACJ,mEADI,CACgEN,CADhE,CACJ,gBADI,CAAN,CAGF,GAAIC,CAAAC,MAAJ,CACE,KAAUK,MAAJ,CAAU,uEAAV,CAAN,CAN+D,CA1FnE,GAAIV,CAAA,YAAJ,EAA4BA,CAAA,YAA5B,CACE,MAAO,CAAA,CAIT,KAAMM,EAAiB,CAAC,OAAD,CAAU,MAAV,CAAkB,mBAAlB,CAUvBK,OAAAC,eAAA,CAAsBX,CAAAY,UAAtB,CAAiD,UAAjD,CAA6D,CAACC,MAAO,OAAR,CAA7D,CAOAb,EAAAY,UAAA,OAAA,CAAsC,QAAQ,CAACE,CAAD;AAASX,CAAT,CAAkC,CAAzBA,CAAA,CAAA,IAAA,EAAA,GAAAA,CAAA,CAAQ,CAACY,OAAQ,CAAA,CAAT,CAAR,CA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,EAAA,YAAA,CAAuBwB,CACvBxB,EAAA,YAAA,CAAuByB,CAxPN,CAAhB,CAAA,CA0PmB,WAAlB,GAAA,MAAOoC,OAAP,CAAgCA,MAAhC,CAA4D,WAAlB,GAAA,MAAOC,OAAP,CAAgCA,MAAhC,CAAyC,IA1PpF;", "sources":["text.js"], -"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","inputIndex","ArrayBuffer","pendingSize","min","pending","Uint16Array","chunks","pendingIndex","more","push","String","fromCharCode","apply","join","byte1","byte2","byte3","byte4","codepoint","window","global"] +"names":["scope","decodeFallback","bytes","inputIndex","pendingSize","Math","min","length","pending","Uint16Array","chunks","pendingIndex","more","push","String","fromCharCode","apply","subarray","join","byte1","byte2","byte3","byte4","codepoint","FastTextEncoder","FastTextDecoder","utfLabel","options","fatal","validUtfLabels","indexOf","toLowerCase","RangeError","Error","decodeBuffer","Buffer","from","buffer","byteOffset","byteLength","toString","Object","defineProperty","prototype","value","string","stream","pos","len","at","tlen","max","target","Uint8Array","charCodeAt","extra","update","set","slice","decodeImpl","ArrayBuffer","window","global"] }