mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
2
node_modules/fast-text-encoding/.npmignore
generated
vendored
Normal file
2
node_modules/fast-text-encoding/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# sample data
|
||||
*.txt
|
201
node_modules/fast-text-encoding/LICENSE
generated
vendored
Normal file
201
node_modules/fast-text-encoding/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
51
node_modules/fast-text-encoding/README.md
generated
vendored
Normal file
51
node_modules/fast-text-encoding/README.md
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
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).
|
||||
|
||||
[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`.
|
||||
|
||||
```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/
|
||||
</script>
|
||||
```
|
||||
|
||||
**Note**: Always include `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:
|
||||
|
||||
```js
|
||||
// don't need to save this anywhere, just require before use
|
||||
require('fast-text-encoding');
|
||||
|
||||
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.
|
||||
|
||||
# Release
|
||||
|
||||
Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home).
|
||||
|
||||
```
|
||||
// ==ClosureCompiler==
|
||||
// @compilation_level ADVANCED_OPTIMIZATIONS
|
||||
// @output_file_name text.min.js
|
||||
// ==/ClosureCompiler==
|
||||
|
||||
// code here
|
||||
```
|
48
node_modules/fast-text-encoding/package.json
generated
vendored
Normal file
48
node_modules/fast-text-encoding/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"fast-text-encoding@1.0.0",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "fast-text-encoding@1.0.0",
|
||||
"_id": "fast-text-encoding@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==",
|
||||
"_location": "/fast-text-encoding",
|
||||
"_optional": true,
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "fast-text-encoding@1.0.0",
|
||||
"name": "fast-text-encoding",
|
||||
"escapedName": "fast-text-encoding",
|
||||
"rawSpec": "1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auth-library"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz",
|
||||
"_spec": "1.0.0",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Sam Thorogood",
|
||||
"email": "sam.thorogood@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/samthor/fast-text-encoder/issues"
|
||||
},
|
||||
"description": "Fast polyfill for TextEncoder and TextDecoder, only supports utf-8",
|
||||
"homepage": "https://github.com/samthor/fast-text-encoder#readme",
|
||||
"license": "Apache-2",
|
||||
"main": "text.min.js",
|
||||
"name": "fast-text-encoding",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/samthor/fast-text-encoder.git"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
10
node_modules/fast-text-encoding/polyfill.js
generated
vendored
Normal file
10
node_modules/fast-text-encoding/polyfill.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
window.module = {
|
||||
exports: {},
|
||||
};
|
||||
|
||||
const hack = new Proxy({}, {
|
||||
get() {
|
||||
return [];
|
||||
},
|
||||
});
|
||||
window.require = () => ({'encoding-indexes': hack});
|
69
node_modules/fast-text-encoding/test.html
generated
vendored
Normal file
69
node_modules/fast-text-encoding/test.html
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<!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>
|
187
node_modules/fast-text-encoding/text.js
generated
vendored
Normal file
187
node_modules/fast-text-encoding/text.js
generated
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright 2017 Sam Thorogood. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Polyfill for TextEncoder and TextDecoder.
|
||||
*
|
||||
* You probably want `text.min.js`, and not this file directly.
|
||||
*/
|
||||
|
||||
(function(scope) {
|
||||
'use strict';
|
||||
|
||||
// fail early
|
||||
if (scope['TextEncoder'] && scope['TextDecoder']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.`);
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'});
|
||||
|
||||
/**
|
||||
* @param {string} string
|
||||
* @param {{stream: boolean}=} options
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
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
|
||||
|
||||
while (pos < len) {
|
||||
let value = string.charCodeAt(pos++);
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < len) {
|
||||
const extra = string.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
continue; // drop lone surrogate
|
||||
}
|
||||
}
|
||||
|
||||
// expand the buffer if we couldn't write 4 bytes
|
||||
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
|
||||
|
||||
const update = new Uint8Array(tlen);
|
||||
update.set(target);
|
||||
target = update;
|
||||
}
|
||||
|
||||
if ((value & 0xffffff80) === 0) { // 1-byte
|
||||
target[at++] = value; // ASCII
|
||||
continue;
|
||||
} else if ((value & 0xfffff800) === 0) { // 2-byte
|
||||
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;
|
||||
} 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;
|
||||
} else {
|
||||
// FIXME: do we care
|
||||
continue;
|
||||
}
|
||||
|
||||
target[at++] = (value & 0x3f) | 0x80;
|
||||
}
|
||||
|
||||
return target.slice(0, at);
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string=} utfLabel
|
||||
* @param {{fatal: boolean}=} options
|
||||
*/
|
||||
function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) {
|
||||
if (utfLabel !== 'utf-8') {
|
||||
throw new RangeError(
|
||||
`Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`);
|
||||
}
|
||||
if (options.fatal) {
|
||||
throw new Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`);
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'encoding', {value: 'utf-8'});
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'fatal', {value: false});
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false});
|
||||
|
||||
/**
|
||||
* @param {(!ArrayBuffer|!ArrayBufferView)} buffer
|
||||
* @param {{stream: boolean}=} options
|
||||
*/
|
||||
FastTextDecoder.prototype.decode = function(buffer, options={stream: false}) {
|
||||
if (options['stream']) {
|
||||
throw new Error(`Failed to decode: the 'stream' option is unsupported.`);
|
||||
}
|
||||
|
||||
const bytes = new Uint8Array(buffer);
|
||||
let pos = 0;
|
||||
const len = bytes.length;
|
||||
const out = [];
|
||||
|
||||
while (pos < len) {
|
||||
const byte1 = bytes[pos++];
|
||||
if (byte1 === 0) {
|
||||
break; // NULL
|
||||
}
|
||||
|
||||
if ((byte1 & 0x80) === 0) { // 1-byte
|
||||
out.push(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;
|
||||
|
||||
// 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)
|
||||
codepoint = 0xdc00 | codepoint & 0x3ff;
|
||||
}
|
||||
out.push(codepoint);
|
||||
} else {
|
||||
// FIXME: we're ignoring this
|
||||
}
|
||||
}
|
||||
|
||||
return String.fromCharCode.apply(null, out);
|
||||
}
|
||||
|
||||
scope['TextEncoder'] = FastTextEncoder;
|
||||
scope['TextDecoder'] = FastTextDecoder;
|
||||
|
||||
}(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));
|
5
node_modules/fast-text-encoding/text.min.js
generated
vendored
Normal file
5
node_modules/fast-text-encoding/text.min.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
(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);
|
Reference in New Issue
Block a user