Updating NPM dependencies
This commit is contained in:
2
node_modules/fast-text-encoding/.npmignore
generated
vendored
2
node_modules/fast-text-encoding/.npmignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
# sample data
|
||||
*.txt
|
||||
4
node_modules/fast-text-encoding/.travis.yml
generated
vendored
Normal file
4
node_modules/fast-text-encoding/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- stable
|
||||
31
node_modules/fast-text-encoding/README.md
generated
vendored
31
node_modules/fast-text-encoding/README.md
generated
vendored
@@ -1,41 +1,48 @@
|
||||
[](https://travis-ci.org/samthor/fast-text-encoding)
|
||||
|
||||
This is a fast polyfill for [`TextEncoder`][1] and [`TextDecoder`][2], which let you encode and decode JavaScript strings into UTF-8 bytes.
|
||||
|
||||
It is fast partially as it does not support any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
|
||||
See [some benchmarks](https://github.com/samthor/fast-text-encoding/tree/master/bench).
|
||||
|
||||
[1]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
|
||||
[2]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
|
||||
|
||||
# Usage
|
||||
|
||||
Include the minified inside a `script` tag or as an ES6 Module for its side-effects.
|
||||
It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `window`.
|
||||
Install as "fast-text-encoding" via your favourite package manager.
|
||||
|
||||
You only need this polyfill if you're supporting older browsers like IE, legacy Edge, ancient Chrome and Firefox, or Node before v11.
|
||||
|
||||
## Browser
|
||||
|
||||
Include the minified code inside a `script` tag or as an ES6 Module for its side effects.
|
||||
It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `window` or `global.`
|
||||
|
||||
```html
|
||||
<script src="node_modules/fast-text-encoding/text.min.js"></script>
|
||||
<script type="module">
|
||||
import './node_modules/fast-text-encoding/text.min.js';
|
||||
// confidently do something with TextEncoder \o/
|
||||
import 'fast-text-encoding'; // or perhaps this
|
||||
// confidently do something with TextEncoder or TextDecoder \o/
|
||||
</script>
|
||||
```
|
||||
|
||||
**Note**: Always include `text.min.js`, as it's compiled to ES5 for older environments.
|
||||
⚠️ You'll probably want to depend on `text.min.js`, as it's compiled to ES5 for older environments.
|
||||
|
||||
## Node
|
||||
|
||||
Install via NPM or Yarn (name "fast-text-encoding"), and then import purely for side effects:
|
||||
You only need this polyfill in Node before v11.
|
||||
However, you can use `Buffer` to provide the same functionality (but not conforming to any spec) in versions even older than that.
|
||||
|
||||
```js
|
||||
// don't need to save this anywhere, just require before use
|
||||
require('fast-text-encoding');
|
||||
require('fast-text-encoding'); // just require me before use
|
||||
|
||||
const buffer = new TextEncoder().encode('Turn me into UTF-8!');
|
||||
// buffer is now a Uint8Array of [84, 117, 114, 110, ...]
|
||||
```
|
||||
|
||||
# Supports
|
||||
|
||||
Built for IE11, Edge and Node environments.
|
||||
Not required for Chrome, Firefox etc, which have native implementations.
|
||||
In Node v5.1 and above, this polyfill uses `Buffer` to implement `TextDecoder`.
|
||||
|
||||
# Release
|
||||
|
||||
@@ -48,4 +55,4 @@ Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home).
|
||||
// ==/ClosureCompiler==
|
||||
|
||||
// code here
|
||||
```
|
||||
```
|
||||
|
||||
10
node_modules/fast-text-encoding/compile.sh
generated
vendored
Executable file
10
node_modules/fast-text-encoding/compile.sh
generated
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
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
|
||||
20
node_modules/fast-text-encoding/externs.js
generated
vendored
Normal file
20
node_modules/fast-text-encoding/externs.js
generated
vendored
Normal file
@@ -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) {};
|
||||
29
node_modules/fast-text-encoding/package.json
generated
vendored
29
node_modules/fast-text-encoding/package.json
generated
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"_from": "fast-text-encoding@^1.0.0",
|
||||
"_id": "fast-text-encoding@1.0.0",
|
||||
"_id": "fast-text-encoding@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==",
|
||||
"_integrity": "sha512-dtm4QZH9nZtcDt8qJiOH9fcQd1NAgi+K1O2DbE6GG1PPCK/BWfOH3idCTRQ4ImXRUOyopDEgDEnVEE7Y/2Wrig==",
|
||||
"_location": "/fast-text-encoding",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
@@ -18,27 +18,36 @@
|
||||
"_requiredBy": [
|
||||
"/google-auth-library"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz",
|
||||
"_shasum": "3e5ce8293409cfaa7177a71b9ca84e1b1e6f25ef",
|
||||
"_resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz",
|
||||
"_shasum": "ec02ac8e01ab8a319af182dae2681213cfe9ce53",
|
||||
"_spec": "fast-text-encoding@^1.0.0",
|
||||
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play/node_modules/google-auth-library",
|
||||
"_where": "/home/codespace/workspace/upload-google-play/node_modules/google-auth-library",
|
||||
"author": {
|
||||
"name": "Sam Thorogood",
|
||||
"email": "sam.thorogood@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/samthor/fast-text-encoder/issues"
|
||||
"url": "https://github.com/samthor/fast-text-encoding/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Fast polyfill for TextEncoder and TextDecoder, only supports utf-8",
|
||||
"homepage": "https://github.com/samthor/fast-text-encoder#readme",
|
||||
"license": "Apache-2",
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"google-closure-compiler": "^20200406.0.0",
|
||||
"mocha": "^7.1.0"
|
||||
},
|
||||
"homepage": "https://github.com/samthor/fast-text-encoding#readme",
|
||||
"license": "Apache-2.0",
|
||||
"main": "text.min.js",
|
||||
"name": "fast-text-encoding",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/samthor/fast-text-encoder.git"
|
||||
"url": "git+https://github.com/samthor/fast-text-encoding.git"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
"scripts": {
|
||||
"compile": "./compile.sh",
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
||||
|
||||
10
node_modules/fast-text-encoding/polyfill.js
generated
vendored
10
node_modules/fast-text-encoding/polyfill.js
generated
vendored
@@ -1,10 +0,0 @@
|
||||
window.module = {
|
||||
exports: {},
|
||||
};
|
||||
|
||||
const hack = new Proxy({}, {
|
||||
get() {
|
||||
return [];
|
||||
},
|
||||
});
|
||||
window.require = () => ({'encoding-indexes': hack});
|
||||
69
node_modules/fast-text-encoding/test.html
generated
vendored
69
node_modules/fast-text-encoding/test.html
generated
vendored
@@ -1,69 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script defer src="https://cdn.rawgit.com/mathiasbynens/utf8.js/5566334e/utf8.js"></script>
|
||||
<script type="module">
|
||||
</script>
|
||||
<script type="module">
|
||||
import './polyfill.js';
|
||||
import 'https://cdn.rawgit.com/inexorabletash/text-encoding/b98ab30b/lib/encoding.js';
|
||||
const polyfill = module.exports;
|
||||
|
||||
import './text.js';
|
||||
|
||||
const runs = 1;
|
||||
const dataUrl = './utf8_sequence_0-0xffff_assigned_printable.txt';
|
||||
|
||||
(async function() {
|
||||
let text = await window.fetch(dataUrl).then((data) => data.text());
|
||||
text = text.substr(0, 10000);
|
||||
|
||||
function testEncodeDecode(name, tenc, tdec) {
|
||||
console.time(name + '.TextEncoder');
|
||||
let saved;
|
||||
const encoder = new tenc();
|
||||
for (let i = 0; i < runs; ++i) {
|
||||
const out = encoder.encode(text);
|
||||
saved = out;
|
||||
}
|
||||
console.info('got output', saved);
|
||||
console.timeEnd(name + '.TextEncoder');
|
||||
|
||||
console.time(name + '.TextDecoder');
|
||||
const decoder = new tdec();
|
||||
for (let i = 0; i < runs; ++i) {
|
||||
const out = decoder.decode(saved);
|
||||
output = out;
|
||||
}
|
||||
console.timeEnd(name + '.TextDecoder');
|
||||
}
|
||||
|
||||
let saved, output;
|
||||
|
||||
console.time('utf8.encode');
|
||||
for (let i = 0; i < runs; ++i) {
|
||||
const s = utf8.encode(text);
|
||||
saved = s;
|
||||
}
|
||||
console.timeEnd('utf8.encode');
|
||||
|
||||
console.time('utf8.decode');
|
||||
for (let i = 0; i < runs; ++i) {
|
||||
const out = utf8.decode(saved);
|
||||
output = out;
|
||||
}
|
||||
console.timeEnd('utf8.decode');
|
||||
if (output !== text) {
|
||||
throw new Error('utf8 got wrong answer');
|
||||
}
|
||||
|
||||
|
||||
testEncodeDecode('native', TextEncoder, TextDecoder);
|
||||
testEncodeDecode('fast', TextEncoderPolyfill, TextDecoderPolyfill);
|
||||
testEncodeDecode('polyfill', polyfill.TextEncoder, polyfill.TextDecoder);
|
||||
|
||||
}());
|
||||
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
195
node_modules/fast-text-encoding/text.js
generated
vendored
195
node_modules/fast-text-encoding/text.js
generated
vendored
@@ -28,15 +28,15 @@ if (scope['TextEncoder'] && scope['TextDecoder']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// used for FastTextDecoder
|
||||
const validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string=} utfLabel
|
||||
*/
|
||||
function FastTextEncoder(utfLabel='utf-8') {
|
||||
if (utfLabel !== 'utf-8') {
|
||||
throw new RangeError(
|
||||
`Failed to construct 'TextEncoder': The encoding label provided ('${utfLabel}') is invalid.`);
|
||||
}
|
||||
function FastTextEncoder() {
|
||||
// This does not accept an encoding, and always uses UTF-8:
|
||||
// https://www.w3.org/TR/encoding/#dom-textencoder
|
||||
}
|
||||
|
||||
Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'});
|
||||
@@ -46,18 +46,17 @@ 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.`);
|
||||
}
|
||||
|
||||
let pos = 0;
|
||||
const len = string.length;
|
||||
const out = [];
|
||||
|
||||
let at = 0; // output position
|
||||
let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
|
||||
let target = new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
|
||||
let tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size
|
||||
let target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset
|
||||
|
||||
while (pos < len) {
|
||||
let value = string.charCodeAt(pos++);
|
||||
@@ -79,7 +78,7 @@ FastTextEncoder.prototype.encode = function(string, options={stream: false}) {
|
||||
if (at + 4 > target.length) {
|
||||
tlen += 8; // minimum extra
|
||||
tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining
|
||||
tlen = (tlen >> 3) << 3; // 8 byte offset
|
||||
tlen = (tlen >>> 3) << 3; // 8 byte offset
|
||||
|
||||
const update = new Uint8Array(tlen);
|
||||
update.set(target);
|
||||
@@ -90,23 +89,24 @@ 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;
|
||||
target[at++] = ((value >>> 12) & 0x0f) | 0xe0;
|
||||
target[at++] = ((value >>> 6) & 0x3f) | 0x80;
|
||||
} else if ((value & 0xffe00000) === 0) { // 4-byte
|
||||
target[at++] = ((value >> 18) & 0x07) | 0xf0;
|
||||
target[at++] = ((value >> 12) & 0x3f) | 0x80;
|
||||
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
||||
target[at++] = ((value >>> 18) & 0x07) | 0xf0;
|
||||
target[at++] = ((value >>> 12) & 0x3f) | 0x80;
|
||||
target[at++] = ((value >>> 6) & 0x3f) | 0x80;
|
||||
} else {
|
||||
// FIXME: do we care
|
||||
continue;
|
||||
continue; // out of range
|
||||
}
|
||||
|
||||
target[at++] = (value & 0x3f) | 0x80;
|
||||
}
|
||||
|
||||
return target.slice(0, at);
|
||||
// Use subarray if slice isn't supported (IE11). This will use more memory
|
||||
// because the original array still exists.
|
||||
return target.slice ? target.slice(0, at) : target.subarray(0, at);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ FastTextEncoder.prototype.encode = function(string, options={stream: false}) {
|
||||
* @param {{fatal: boolean}=} options
|
||||
*/
|
||||
function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) {
|
||||
if (utfLabel !== 'utf-8') {
|
||||
if (validUtfLabels.indexOf(utfLabel.toLowerCase()) === -1) {
|
||||
throw new RangeError(
|
||||
`Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`);
|
||||
}
|
||||
@@ -131,54 +131,147 @@ 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], {type: 'text/plain;charset=UTF-8'});
|
||||
const u = URL.createObjectURL(b);
|
||||
|
||||
// This hack will fail in non-Edgium Edge because sync XHRs are disabled (and
|
||||
// possibly in other places), so ensure there's a fallback call.
|
||||
try {
|
||||
const x = new XMLHttpRequest();
|
||||
x.open('GET', u, false);
|
||||
x.send();
|
||||
return x.responseText;
|
||||
} catch (e) {
|
||||
return decodeFallback(bytes);
|
||||
} finally {
|
||||
URL.revokeObjectURL(u);
|
||||
}
|
||||
}
|
||||
|
||||
const bytes = new Uint8Array(buffer);
|
||||
let pos = 0;
|
||||
const len = bytes.length;
|
||||
const out = [];
|
||||
/**
|
||||
* @param {!Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
function decodeFallback(bytes) {
|
||||
let inputIndex = 0;
|
||||
|
||||
while (pos < len) {
|
||||
const byte1 = bytes[pos++];
|
||||
if (byte1 === 0) {
|
||||
break; // NULL
|
||||
// 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, bytes.length + 1);
|
||||
const pending = new Uint16Array(pendingSize);
|
||||
const chunks = [];
|
||||
let pendingIndex = 0;
|
||||
|
||||
for (;;) {
|
||||
const more = inputIndex < bytes.length;
|
||||
|
||||
// If there's no more data or there'd be no room for two UTF-16 values,
|
||||
// create a chunk. This isn't done at the end by simply slicing the data
|
||||
// into equal sized chunks as we might hit a surrogate pair.
|
||||
if (!more || (pendingIndex >= pendingSize - 1)) {
|
||||
// nb. .apply and friends are *really slow*. Low-hanging fruit is to
|
||||
// expand this to literally pass pending[0], pending[1], ... etc, but
|
||||
// the output code expands pretty fast in this case.
|
||||
chunks.push(String.fromCharCode.apply(null, pending.subarray(0, pendingIndex)));
|
||||
|
||||
if (!more) {
|
||||
return chunks.join('');
|
||||
}
|
||||
|
||||
// Move the buffer forward and create another chunk.
|
||||
bytes = bytes.subarray(inputIndex);
|
||||
inputIndex = 0;
|
||||
pendingIndex = 0;
|
||||
}
|
||||
|
||||
if ((byte1 & 0x80) === 0) { // 1-byte
|
||||
out.push(byte1);
|
||||
|
||||
// The native TextDecoder will generate "REPLACEMENT CHARACTER" where the
|
||||
// input data is invalid. Here, we blindly parse the data even if it's
|
||||
// wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.
|
||||
|
||||
const byte1 = bytes[inputIndex++];
|
||||
if ((byte1 & 0x80) === 0) { // 1-byte or null
|
||||
pending[pendingIndex++] = byte1;
|
||||
} else if ((byte1 & 0xe0) === 0xc0) { // 2-byte
|
||||
const byte2 = bytes[pos++] & 0x3f;
|
||||
out.push(((byte1 & 0x1f) << 6) | byte2);
|
||||
} else if ((byte1 & 0xf0) === 0xe0) {
|
||||
const byte2 = bytes[pos++] & 0x3f;
|
||||
const byte3 = bytes[pos++] & 0x3f;
|
||||
out.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3);
|
||||
} else if ((byte1 & 0xf8) === 0xf0) {
|
||||
const byte2 = bytes[pos++] & 0x3f;
|
||||
const byte3 = bytes[pos++] & 0x3f;
|
||||
const byte4 = bytes[pos++] & 0x3f;
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;
|
||||
} else if ((byte1 & 0xf0) === 0xe0) { // 3-byte
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
const byte3 = bytes[inputIndex++] & 0x3f;
|
||||
pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;
|
||||
} else if ((byte1 & 0xf8) === 0xf0) { // 4-byte
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
const byte3 = bytes[inputIndex++] & 0x3f;
|
||||
const byte4 = bytes[inputIndex++] & 0x3f;
|
||||
|
||||
// this can be > 0xffff, so possibly generate surrogates
|
||||
let codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
|
||||
if (codepoint > 0xffff) {
|
||||
// codepoint &= ~0x10000;
|
||||
codepoint -= 0x10000;
|
||||
out.push((codepoint >>> 10) & 0x3ff | 0xd800)
|
||||
pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;
|
||||
codepoint = 0xdc00 | codepoint & 0x3ff;
|
||||
}
|
||||
out.push(codepoint);
|
||||
pending[pendingIndex++] = codepoint;
|
||||
} else {
|
||||
// FIXME: we're ignoring this
|
||||
// invalid initial byte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return String.fromCharCode.apply(null, out);
|
||||
// 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), ...
|
||||
decodeImpl = decodeSyncXHR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.`);
|
||||
}
|
||||
|
||||
let bytes;
|
||||
|
||||
if (buffer instanceof Uint8Array) {
|
||||
// Accept Uint8Array instances as-is.
|
||||
bytes = buffer;
|
||||
} else if (buffer.buffer instanceof ArrayBuffer) {
|
||||
// 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.
|
||||
bytes = new Uint8Array(buffer.buffer);
|
||||
} else {
|
||||
// The only other valid argument here is that "buffer" is an ArrayBuffer.
|
||||
// We also try to convert anything else passed to a Uint8Array, as this
|
||||
// catches anything that's array-like. Native code would throw here.
|
||||
bytes = new Uint8Array(buffer);
|
||||
}
|
||||
|
||||
return decodeImpl(/** @type {!Uint8Array} */ (bytes));
|
||||
}
|
||||
|
||||
scope['TextEncoder'] = FastTextEncoder;
|
||||
|
||||
11
node_modules/fast-text-encoding/text.min.js
generated
vendored
11
node_modules/fast-text-encoding/text.min.js
generated
vendored
@@ -1,5 +1,6 @@
|
||||
(function(l){function m(b){b=void 0===b?"utf-8":b;if("utf-8"!==b)throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+b+"') is invalid.");}function k(b,a){b=void 0===b?"utf-8":b;a=void 0===a?{fatal:!1}:a;if("utf-8"!==b)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+b+"') is invalid.");if(a.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}if(l.TextEncoder&&l.TextDecoder)return!1;
|
||||
Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(b,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=b.length,f=0,c=Math.max(32,h+(h>>1)+7),e=new Uint8Array(c>>3<<3);a<h;){var d=b.charCodeAt(a++);if(55296<=d&&56319>=d){if(a<h){var g=b.charCodeAt(a);56320===(g&64512)&&(++a,d=((d&1023)<<10)+(g&1023)+65536)}if(55296<=d&&56319>=d)continue}f+4>e.length&&(c+=8,c*=1+a/b.length*2,c=c>>3<<3,
|
||||
g=new Uint8Array(c),g.set(e),e=g);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(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(b,a){a=void 0===a?{stream:!1}:a;if(a.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");b=new Uint8Array(b);a=0;for(var h=b.length,f=[];a<h;){var c=b[a++];if(0===c)break;if(0===(c&128))f.push(c);else if(192===(c&224)){var e=b[a++]&63;f.push((c&31)<<6|e)}else if(224===(c&240)){e=b[a++]&63;var d=b[a++]&63;f.push((c&31)<<12|e<<6|d)}else if(240===(c&248)){e=b[a++]&63;d=b[a++]&63;var g=b[a++]&63;c=(c&7)<<18|e<<12|d<<6|g;65535<c&&(c-=65536,f.push(c>>>10&1023|55296),c=56320|
|
||||
c&1023);f.push(c)}}return String.fromCharCode.apply(null,f)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this);
|
||||
(function(l){function m(){}function k(a,c){a=void 0===a?"utf-8":a;c=void 0===c?{fatal:!1}:c;if(-1===r.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}function t(a){return Buffer.from(a.buffer,a.byteOffset,a.byteLength).toString("utf-8")}function u(a){var c=URL.createObjectURL(new Blob([a],{type:"text/plain;charset=UTF-8"}));
|
||||
try{var f=new XMLHttpRequest;f.open("GET",c,!1);f.send();return f.responseText}catch(e){return q(a)}finally{URL.revokeObjectURL(c)}}function q(a){for(var c=0,f=Math.min(65536,a.length+1),e=new Uint16Array(f),h=[],d=0;;){var b=c<a.length;if(!b||d>=f-1){h.push(String.fromCharCode.apply(null,e.subarray(0,d)));if(!b)return h.join("");a=a.subarray(c);d=c=0}b=a[c++];if(0===(b&128))e[d++]=b;else if(192===(b&224)){var g=a[c++]&63;e[d++]=(b&31)<<6|g}else if(224===(b&240)){g=a[c++]&63;var n=a[c++]&63;e[d++]=
|
||||
(b&31)<<12|g<<6|n}else if(240===(b&248)){g=a[c++]&63;n=a[c++]&63;var v=a[c++]&63;b=(b&7)<<18|g<<12|n<<6|v;65535<b&&(b-=65536,e[d++]=b>>>10&1023|55296,b=56320|b&1023);e[d++]=b}}}if(l.TextEncoder&&l.TextDecoder)return!1;var r=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var f=a.length,e=0,h=Math.max(32,
|
||||
f+(f>>>1)+7),d=new Uint8Array(h>>>3<<3);c<f;){var b=a.charCodeAt(c++);if(55296<=b&&56319>=b){if(c<f){var g=a.charCodeAt(c);56320===(g&64512)&&(++c,b=((b&1023)<<10)+(g&1023)+65536)}if(55296<=b&&56319>=b)continue}e+4>d.length&&(h+=8,h*=1+c/a.length*2,h=h>>>3<<3,g=new Uint8Array(h),g.set(d),d=g);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});var p=q;"function"===typeof Buffer&&Buffer.from?p=t:"function"===typeof Blob&&"function"===typeof URL&&"function"===typeof URL.createObjectURL&&(p=u);k.prototype.decode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");
|
||||
a=a instanceof Uint8Array?a:a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer):new Uint8Array(a);return p(a)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this);
|
||||
|
||||
8
node_modules/fast-text-encoding/text.min.js.map
generated
vendored
Normal file
8
node_modules/fast-text-encoding/text.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user