├── .github
└── workflows
│ └── node.js.yml
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── bench
├── .gitignore
├── README.md
├── compare.js
├── package.json
└── yarn.lock
├── build.js
├── empty-package
├── LICENSE
├── README.md
├── empty.js
└── package.json
├── package-lock.json
├── package.json
├── package
└── package.json
├── release.sh
├── src
├── buffer.js
├── lowlevel.js
├── o-decoder.js
├── o-encoder.js
├── polyfill.js
├── shared.js
├── support.js
└── xhr.js
├── test-setup.js
├── test.html
├── test.js
├── text.min.js
├── text.min.js.map
└── tsconfig.json
/.github/workflows/node.js.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3 |
4 | name: Test
5 |
6 | on:
7 | push:
8 | branches: [ "master" ]
9 | pull_request:
10 | branches: [ "master" ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | strategy:
18 | matrix:
19 | node-version: [18.x]
20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21 |
22 | steps:
23 | - uses: actions/checkout@v3
24 | - name: Use Node.js ${{ matrix.node-version }}
25 | uses: actions/setup-node@v3
26 | with:
27 | node-version: ${{ matrix.node-version }}
28 | cache: 'npm'
29 | - run: npm ci
30 | - run: npm run build --if-present
31 | - run: npm test
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | yarn-error.log
4 |
5 | package/*
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .github/
2 | *.sh
3 | test.*
4 | test-setup.*
5 | suite.*
6 | bench/
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/samthor/fast-text-encoding/actions/workflows/node.js.yml)
2 |
3 | This is a fast polyfill for [`TextEncoder`][1] and [`TextDecoder`][2], which let you encode and decode JavaScript strings into UTF-8 bytes.
4 |
5 | It is fast partially as it does not support^ any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
6 | See [some benchmarks](https://github.com/samthor/fast-text-encoding/tree/master/bench).
7 |
8 | ^If this polyfill used on Node v5.1 through v11 (when `Text...` was introduced), then this simply wraps `Buffer`, which supports many encodings and is native code.
9 |
10 | [1]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
11 | [2]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
12 |
13 | # Usage
14 |
15 | Install as "fast-text-encoding" via your favourite package manager.
16 |
17 | You only need this polyfill if you're supporting older browsers like IE, legacy Edge, ancient Chrome and Firefox, or Node before v11.
18 |
19 | ## Browser
20 |
21 | Include the minified code inside a `
26 |
31 | ```
32 |
33 | ⚠️ You'll probably want to depend on "text.min.js", as it's compiled to ES5 for older environments.
34 |
35 | ## Not Including Polyfill
36 |
37 | If your project doesn't need the polyfill, but is included as a transitive dependency, we publish [an empty version](https://www.npmjs.com/package/fast-text-encoding/v/0.0.0-empty) that you could pin NPM or similar's version algorithm to.
38 | Use "fast-text-encoding@empty".
39 |
--------------------------------------------------------------------------------
/bench/.gitignore:
--------------------------------------------------------------------------------
1 | *.txt
2 |
--------------------------------------------------------------------------------
/bench/README.md:
--------------------------------------------------------------------------------
1 | Benchmark code for Node, which encodes and decodes a string.
2 | Usage:
3 |
4 | ```bash
5 | ./compare.js
6 | # or
7 | ./compare.js
8 | ```
9 |
10 | If you don't provide a source file, or specify a length instead, this will generate actual random text in JavaScript.
11 |
12 | For a better test, use suggested UTF-8 encoded source text from [Project Gutenberg](https://www.gutenberg.org/files/23841/23841-0.txt).
13 | The linked file has a "bytes-to-length" ratio of 0.35.
14 |
15 | This ratio compares the on-disk UTF-8 bytes (which optimize for ASCII and other low Unicode values) to the length of JavaScript's UCS-2 / UTF-16 internal representation.
16 | All Unicode code points can be represented as either one or two "lengths" of a JavaScript string, but each code point can be between 1-4 bytes in UTF-8.
17 | The valid ratios therefore range from ⅓ through 1.0 (e.g., ASCII).
18 |
19 | # Options
20 |
21 | By default, the benchmark tool disables and removes native-like implementations in Node.
22 | It removes `Buffer` plus the native `TextEncoder` and `TextDecoder` from the global scope.
23 |
24 | Use `--native` to retain `Buffer`, which will speed up `fast-text-encoding`.
25 |
26 | # Results
27 |
28 | As you'd expect, the native implementation is the speediest.
29 | There's a bit of noise in the test; it's not perfect.
30 |
31 | Tests on macOS, 3.6ghz i9, "fast-text-encoding" version 1.0.2.
32 |
33 | ## Low Ratio
34 |
35 | Using the mentioned [test file](https://www.gutenberg.org/files/23841/23841-0.txt).
36 |
37 | ```
38 | compare (file): length=971478, bytes=2740678 (ratio=0.35)
39 | native speedups allowed? NO!
40 |
41 | 10.2111ms .native 971477
42 | 10.3203ms .native 971477
43 | 10.9366ms .native 971477
44 | 11.0249ms .native 971477
45 | 11.6899ms .native 971477
46 | 12.0494ms .native 971477
47 | 36.8205ms fast-text-encoding
48 | 38.8506ms fast-text-encoding
49 | 42.8944ms fast-text-encoding
50 | 47.1252ms fast-text-encoding
51 | 53.2264ms fast-text-encoding
52 | 54.3824ms fast-text-encoding
53 | 134.3251ms fastestsmallesttextencoderdecoder
54 | 136.6160ms fastestsmallesttextencoderdecoder
55 | 136.6426ms fastestsmallesttextencoderdecoder
56 | 137.1191ms fastestsmallesttextencoderdecoder
57 | 138.0675ms fastestsmallesttextencoderdecoder
58 | 139.7024ms fastestsmallesttextencoderdecoder
59 | 470.6317ms text-encoding 971477
60 | 473.9435ms text-encoding-polyfill 971477
61 | 475.3746ms text-encoding-polyfill 971477
62 | 475.5197ms text-encoding 971477
63 | 479.5304ms text-encoding-polyfill 971477
64 | 481.5665ms text-encoding-polyfill 971477
65 | 482.3216ms text-encoding-polyfill 971477
66 | 485.8300ms text-encoding 971477
67 | 488.6046ms text-encoding-polyfill 971477
68 | 490.6234ms text-encoding 971477
69 | 493.1231ms text-encoding 971477
70 | 493.4262ms text-encoding 971477
71 | ```
72 |
73 | ## High Ratio
74 |
75 | UTF-8 text which mostly looks like ASCII, [from here](https://www.gutenberg.org/ebooks/44217.txt.utf-8).
76 |
77 | ```
78 | compare (file): length=99190, bytes=101960 (ratio=0.97)
79 | native speedups allowed? NO!
80 |
81 | 0.3634ms .native 99189
82 | 0.6308ms .native 99189
83 | 0.6374ms .native 99189
84 | 0.6768ms .native 99189
85 | 0.8520ms .native 99189
86 | 0.8711ms .native 99189
87 | 2.2705ms fastestsmallesttextencoderdecoder
88 | 2.2917ms fastestsmallesttextencoderdecoder
89 | 2.3838ms fastestsmallesttextencoderdecoder
90 | 2.9010ms fast-text-encoding
91 | 3.3695ms fast-text-encoding
92 | 3.4776ms fast-text-encoding
93 | 7.5336ms fast-text-encoding
94 | 8.3014ms fastestsmallesttextencoderdecoder
95 | 9.4051ms fastestsmallesttextencoderdecoder
96 | 10.0201ms fastestsmallesttextencoderdecoder
97 | 10.7546ms fast-text-encoding
98 | 12.2336ms fast-text-encoding
99 | 16.4143ms text-encoding-polyfill 99189
100 | 16.6515ms text-encoding-polyfill 99189
101 | 17.1320ms text-encoding 99189
102 | 17.8296ms text-encoding 99189
103 | 23.5324ms text-encoding-polyfill 99189
104 | 23.5962ms text-encoding 99189
105 | 25.2543ms text-encoding 99189
106 | 25.5921ms text-encoding 99189
107 | 26.2855ms text-encoding-polyfill 99189
108 | 27.0913ms text-encoding-polyfill 99189
109 | 30.2643ms text-encoding 99189
110 | 32.3319ms text-encoding-polyfill 99189
111 | ```
112 |
--------------------------------------------------------------------------------
/bench/compare.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node --max-old-space-size=8192
2 |
3 | const {performance} = require('perf_hooks');
4 | const chalk = require('chalk');
5 | const fs = require('fs');
6 | const mri = require('mri');
7 |
8 | const options = mri(process.argv.slice(2), {
9 | default: {
10 | runs: 6,
11 | native: false,
12 | local: false,
13 | },
14 | });
15 |
16 | const packages = ['fast-text-encoding', 'text-encoding', 'text-encoding-polyfill', 'text-encoding-utf-8', 'fastestsmallesttextencoderdecoder'];
17 |
18 | const NativeTextEncoder = global.TextEncoder;
19 | const NativeTextDecoder = global.TextDecoder;
20 |
21 | function deleteGlobals() {
22 | delete global.TextEncoder;
23 | delete global.TextDecoder;
24 | if (!options.native) {
25 | delete global.Buffer;
26 | }
27 | }
28 |
29 | function buildRandomString(length) {
30 | const parts = [];
31 | for (let i = 0; i < length; ++i) {
32 | const v = 1.0 - Math.pow(Math.random(), 0.25); // bias towards start
33 | parts.push(Math.floor(v * 0x10FFFF));
34 | }
35 | return String.fromCodePoint(...parts);
36 | }
37 |
38 | let string;
39 |
40 | const firstArg = options._[0];
41 | if (firstArg === undefined || +firstArg) {
42 | // possibly a number
43 | string = buildRandomString(+firstArg || (256 * 256));
44 | console.info(`compare (random): length=${chalk.yellow(string.length)}`);
45 | } else {
46 | const stat = fs.statSync(firstArg);
47 | string = fs.readFileSync(firstArg, 'utf-8');
48 | const ratio = (string.length / stat.size);
49 | console.info(`compare (file): length=${chalk.yellow(string.length)}, bytes=${chalk.yellow(stat.size)} (ratio=${chalk.yellow(ratio.toFixed(2))})`);
50 | }
51 |
52 | console.info('native speedups allowed?', chalk.red(options.native ? 'YES' : 'NO!'));
53 | console.info('');
54 |
55 | // remove 'text-encoding-utf-8' after a certain size as it's just pathologically bad
56 | if (string.length >= 32768) {
57 | const index = packages.indexOf('text-encoding-utf-8');
58 | if (index !== -1) {
59 | packages.splice(index, 1);
60 | }
61 | }
62 |
63 | const impl = {};
64 |
65 | for (const name of packages) {
66 | deleteGlobals();
67 | const exports = require(name);
68 | const use = {TextEncoder: global.TextEncoder, TextDecoder: global.TextDecoder, ...exports};
69 |
70 | if (use.TextDecoder === NativeTextDecoder || use.TextEncoder === NativeTextEncoder) {
71 | throw new Error(`package ${name} used native code`);
72 | }
73 |
74 | impl[name] = use;
75 | }
76 |
77 | if (options.local) {
78 | deleteGlobals();
79 |
80 | try {
81 | require('../text.min.js');
82 | packages.push('.local');
83 | impl['.local'] = {TextEncoder: global.TextEncoder, TextDecoder: global.TextDecoder};
84 | } catch (e) {
85 | // ignore
86 | }
87 | }
88 |
89 | deleteGlobals();
90 |
91 | if (NativeTextDecoder && NativeTextEncoder) {
92 | packages.push('.native');
93 | impl['.native'] = {TextEncoder: NativeTextEncoder, TextDecoder: NativeTextDecoder};
94 | }
95 |
96 | (async function() {
97 | const results = [];
98 |
99 | function run(use, s) {
100 | const te = new use.TextEncoder('utf-8');
101 | const data = te.encode(s);
102 |
103 | const td = new use.TextDecoder('utf-8');
104 | const outs = td.decode(data);
105 |
106 | return outs.length;
107 | }
108 |
109 | function shuffle(arr) {
110 | const out = [];
111 | while (arr.length) {
112 | const choice = Math.floor(Math.random() * arr.length);
113 | out.push(arr.splice(choice, 1)[0]);
114 | }
115 | arr.push(...out);
116 | }
117 |
118 | for (let i = 0; i < options.runs; ++i) {
119 | shuffle(packages);
120 | console.info('run', (i + 1));
121 |
122 | for (const name of packages) {
123 | console.debug(chalk.gray(name));
124 | const use = impl[name];
125 |
126 | const start = performance.now();
127 | const length = run(use, string);
128 | const duration = performance.now() - start;
129 | results.push({name, duration, length});
130 |
131 | // take a breather
132 | await new Promise((r) => setTimeout(r, 100));
133 | }
134 | }
135 |
136 | results.sort(({duration: a}, {duration: b}) => a - b);
137 |
138 | for (const {name, duration, length} of results) {
139 | console.info((duration.toFixed(4) + 'ms').padStart(11), chalk.green(name), length !== string.length ? chalk.red(length) : '');
140 | }
141 |
142 | })();
143 |
--------------------------------------------------------------------------------
/bench/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "chalk": "^4.0.0",
4 | "fast-text-encoding": "^1.0.2",
5 | "fastestsmallesttextencoderdecoder": "^1.0.21",
6 | "mri": "^1.1.5",
7 | "text-encoding": "^0.7.0",
8 | "text-encoding-polyfill": "^0.6.7",
9 | "text-encoding-utf-8": "^1.0.2"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/bench/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@types/color-name@^1.1.1":
6 | version "1.1.1"
7 | resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
8 | integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
9 |
10 | ansi-styles@^4.1.0:
11 | version "4.2.1"
12 | resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
13 | integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
14 | dependencies:
15 | "@types/color-name" "^1.1.1"
16 | color-convert "^2.0.1"
17 |
18 | chalk@^4.0.0:
19 | version "4.0.0"
20 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.0.0.tgz#6e98081ed2d17faab615eb52ac66ec1fe6209e72"
21 | integrity sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==
22 | dependencies:
23 | ansi-styles "^4.1.0"
24 | supports-color "^7.1.0"
25 |
26 | color-convert@^2.0.1:
27 | version "2.0.1"
28 | resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
29 | integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
30 | dependencies:
31 | color-name "~1.1.4"
32 |
33 | color-name@~1.1.4:
34 | version "1.1.4"
35 | resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
36 | integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
37 |
38 | fast-text-encoding@^1.0.2:
39 | version "1.0.2"
40 | resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.2.tgz#ff1ad5677bde049e0f8656aa6083a7ef2c5836e2"
41 | integrity sha512-5rQdinSsycpzvAoHga2EDn+LRX1d5xLFsuNG0Kg61JrAT/tASXcLL0nf/33v+sAxlQcfYmWbTURa1mmAf55jGw==
42 |
43 | fastestsmallesttextencoderdecoder@^1.0.21:
44 | version "1.0.21"
45 | resolved "https://registry.yarnpkg.com/fastestsmallesttextencoderdecoder/-/fastestsmallesttextencoderdecoder-1.0.21.tgz#b67599f879417229bad311c9e1f2918dfd155c63"
46 | integrity sha512-43gkbs+ruBXej0jhqcOKZ/DfKJmdWXrHZ5ZeHfYdnJ53aqU+p4JfhZrcNHBLNswieV7DOlj6f4q/+Fw9YMy/5Q==
47 |
48 | has-flag@^4.0.0:
49 | version "4.0.0"
50 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
51 | integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
52 |
53 | mri@^1.1.5:
54 | version "1.1.5"
55 | resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.5.tgz#ce21dba2c69f74a9b7cf8a1ec62307e089e223e0"
56 | integrity sha512-d2RKzMD4JNyHMbnbWnznPaa8vbdlq/4pNZ3IgdaGrVbBhebBsGUUE/6qorTMYNS6TwuH3ilfOlD2bf4Igh8CKg==
57 |
58 | supports-color@^7.1.0:
59 | version "7.1.0"
60 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1"
61 | integrity sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==
62 | dependencies:
63 | has-flag "^4.0.0"
64 |
65 | text-encoding-polyfill@^0.6.7:
66 | version "0.6.7"
67 | resolved "https://registry.yarnpkg.com/text-encoding-polyfill/-/text-encoding-polyfill-0.6.7.tgz#4d27de0153e4c86eb2631ffd74c2f3f57969a9ec"
68 | integrity sha512-/DZ1XJqhbqRkCop6s9ZFu8JrFRwmVuHg4quIRm+ziFkR3N3ec6ck6yBvJ1GYeEQZhLVwRW0rZE+C3SSJpy0RTg==
69 |
70 | text-encoding-utf-8@^1.0.2:
71 | version "1.0.2"
72 | resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13"
73 | integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==
74 |
75 | text-encoding@^0.7.0:
76 | version "0.7.0"
77 | resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643"
78 | integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==
79 |
--------------------------------------------------------------------------------
/build.js:
--------------------------------------------------------------------------------
1 | import * as esbuild from 'esbuild';
2 | import * as fs from 'fs';
3 |
4 | const out = esbuild.buildSync({
5 | entryPoints: ['src/polyfill.js'],
6 | bundle: true,
7 | format: 'esm',
8 | banner: {
9 | js: `(function(scope) {'use strict';`,
10 | },
11 | footer: {
12 | js: `}(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));`,
13 | },
14 | platform: 'neutral',
15 | sourcemap: 'external',
16 | outfile: 'text.min.js',
17 | target: 'es5',
18 | minify: true,
19 | });
20 |
21 | // confirm it imports
22 | await import('./text.min.js');
23 |
24 | const stat = fs.statSync('text.min.js');
25 | console.info(`text.min.js: ${stat.size}`);
26 |
--------------------------------------------------------------------------------
/empty-package/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/empty-package/README.md:
--------------------------------------------------------------------------------
1 | This is an intentionally empty package in case you don't need `fast-text-encoding`.
--------------------------------------------------------------------------------
/empty-package/empty.js:
--------------------------------------------------------------------------------
1 | // Intentionally empty.
--------------------------------------------------------------------------------
/empty-package/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fast-text-encoding",
3 | "version": "0.0.0-empty",
4 | "description": "Empty version of `fast-text-encoding`",
5 | "main": "empty.js",
6 | "repository": "https://github.com/samthor/fast-text-encoding.git",
7 | "author": "Sam Thorogood ",
8 | "license": "Apache-2.0"
9 | }
10 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fast-text-encoding",
3 | "version": "1.0.4",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "fast-text-encoding",
9 | "version": "1.0.4",
10 | "license": "Apache-2.0",
11 | "devDependencies": {
12 | "@types/node": "^18.7.13",
13 | "esbuild": "^0.15.5"
14 | }
15 | },
16 | "node_modules/@esbuild/linux-loong64": {
17 | "version": "0.15.5",
18 | "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.5.tgz",
19 | "integrity": "sha512-UHkDFCfSGTuXq08oQltXxSZmH1TXyWsL+4QhZDWvvLl6mEJQqk3u7/wq1LjhrrAXYIllaTtRSzUXl4Olkf2J8A==",
20 | "cpu": [
21 | "loong64"
22 | ],
23 | "dev": true,
24 | "optional": true,
25 | "os": [
26 | "linux"
27 | ],
28 | "engines": {
29 | "node": ">=12"
30 | }
31 | },
32 | "node_modules/@types/node": {
33 | "version": "18.7.13",
34 | "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
35 | "integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
36 | "dev": true
37 | },
38 | "node_modules/esbuild": {
39 | "version": "0.15.5",
40 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.5.tgz",
41 | "integrity": "sha512-VSf6S1QVqvxfIsSKb3UKr3VhUCis7wgDbtF4Vd9z84UJr05/Sp2fRKmzC+CSPG/dNAPPJZ0BTBLTT1Fhd6N9Gg==",
42 | "dev": true,
43 | "hasInstallScript": true,
44 | "bin": {
45 | "esbuild": "bin/esbuild"
46 | },
47 | "engines": {
48 | "node": ">=12"
49 | },
50 | "optionalDependencies": {
51 | "@esbuild/linux-loong64": "0.15.5",
52 | "esbuild-android-64": "0.15.5",
53 | "esbuild-android-arm64": "0.15.5",
54 | "esbuild-darwin-64": "0.15.5",
55 | "esbuild-darwin-arm64": "0.15.5",
56 | "esbuild-freebsd-64": "0.15.5",
57 | "esbuild-freebsd-arm64": "0.15.5",
58 | "esbuild-linux-32": "0.15.5",
59 | "esbuild-linux-64": "0.15.5",
60 | "esbuild-linux-arm": "0.15.5",
61 | "esbuild-linux-arm64": "0.15.5",
62 | "esbuild-linux-mips64le": "0.15.5",
63 | "esbuild-linux-ppc64le": "0.15.5",
64 | "esbuild-linux-riscv64": "0.15.5",
65 | "esbuild-linux-s390x": "0.15.5",
66 | "esbuild-netbsd-64": "0.15.5",
67 | "esbuild-openbsd-64": "0.15.5",
68 | "esbuild-sunos-64": "0.15.5",
69 | "esbuild-windows-32": "0.15.5",
70 | "esbuild-windows-64": "0.15.5",
71 | "esbuild-windows-arm64": "0.15.5"
72 | }
73 | },
74 | "node_modules/esbuild-android-64": {
75 | "version": "0.15.5",
76 | "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.5.tgz",
77 | "integrity": "sha512-dYPPkiGNskvZqmIK29OPxolyY3tp+c47+Fsc2WYSOVjEPWNCHNyqhtFqQadcXMJDQt8eN0NMDukbyQgFcHquXg==",
78 | "cpu": [
79 | "x64"
80 | ],
81 | "dev": true,
82 | "optional": true,
83 | "os": [
84 | "android"
85 | ],
86 | "engines": {
87 | "node": ">=12"
88 | }
89 | },
90 | "node_modules/esbuild-android-arm64": {
91 | "version": "0.15.5",
92 | "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.5.tgz",
93 | "integrity": "sha512-YyEkaQl08ze3cBzI/4Cm1S+rVh8HMOpCdq8B78JLbNFHhzi4NixVN93xDrHZLztlocEYqi45rHHCgA8kZFidFg==",
94 | "cpu": [
95 | "arm64"
96 | ],
97 | "dev": true,
98 | "optional": true,
99 | "os": [
100 | "android"
101 | ],
102 | "engines": {
103 | "node": ">=12"
104 | }
105 | },
106 | "node_modules/esbuild-darwin-64": {
107 | "version": "0.15.5",
108 | "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.5.tgz",
109 | "integrity": "sha512-Cr0iIqnWKx3ZTvDUAzG0H/u9dWjLE4c2gTtRLz4pqOBGjfjqdcZSfAObFzKTInLLSmD0ZV1I/mshhPoYSBMMCQ==",
110 | "cpu": [
111 | "x64"
112 | ],
113 | "dev": true,
114 | "optional": true,
115 | "os": [
116 | "darwin"
117 | ],
118 | "engines": {
119 | "node": ">=12"
120 | }
121 | },
122 | "node_modules/esbuild-darwin-arm64": {
123 | "version": "0.15.5",
124 | "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.5.tgz",
125 | "integrity": "sha512-WIfQkocGtFrz7vCu44ypY5YmiFXpsxvz2xqwe688jFfSVCnUsCn2qkEVDo7gT8EpsLOz1J/OmqjExePL1dr1Kg==",
126 | "cpu": [
127 | "arm64"
128 | ],
129 | "dev": true,
130 | "optional": true,
131 | "os": [
132 | "darwin"
133 | ],
134 | "engines": {
135 | "node": ">=12"
136 | }
137 | },
138 | "node_modules/esbuild-freebsd-64": {
139 | "version": "0.15.5",
140 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.5.tgz",
141 | "integrity": "sha512-M5/EfzV2RsMd/wqwR18CELcenZ8+fFxQAAEO7TJKDmP3knhWSbD72ILzrXFMMwshlPAS1ShCZ90jsxkm+8FlaA==",
142 | "cpu": [
143 | "x64"
144 | ],
145 | "dev": true,
146 | "optional": true,
147 | "os": [
148 | "freebsd"
149 | ],
150 | "engines": {
151 | "node": ">=12"
152 | }
153 | },
154 | "node_modules/esbuild-freebsd-arm64": {
155 | "version": "0.15.5",
156 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.5.tgz",
157 | "integrity": "sha512-2JQQ5Qs9J0440F/n/aUBNvY6lTo4XP/4lt1TwDfHuo0DY3w5++anw+jTjfouLzbJmFFiwmX7SmUhMnysocx96w==",
158 | "cpu": [
159 | "arm64"
160 | ],
161 | "dev": true,
162 | "optional": true,
163 | "os": [
164 | "freebsd"
165 | ],
166 | "engines": {
167 | "node": ">=12"
168 | }
169 | },
170 | "node_modules/esbuild-linux-32": {
171 | "version": "0.15.5",
172 | "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.5.tgz",
173 | "integrity": "sha512-gO9vNnIN0FTUGjvTFucIXtBSr1Woymmx/aHQtuU+2OllGU6YFLs99960UD4Dib1kFovVgs59MTXwpFdVoSMZoQ==",
174 | "cpu": [
175 | "ia32"
176 | ],
177 | "dev": true,
178 | "optional": true,
179 | "os": [
180 | "linux"
181 | ],
182 | "engines": {
183 | "node": ">=12"
184 | }
185 | },
186 | "node_modules/esbuild-linux-64": {
187 | "version": "0.15.5",
188 | "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.5.tgz",
189 | "integrity": "sha512-ne0GFdNLsm4veXbTnYAWjbx3shpNKZJUd6XpNbKNUZaNllDZfYQt0/zRqOg0sc7O8GQ+PjSMv9IpIEULXVTVmg==",
190 | "cpu": [
191 | "x64"
192 | ],
193 | "dev": true,
194 | "optional": true,
195 | "os": [
196 | "linux"
197 | ],
198 | "engines": {
199 | "node": ">=12"
200 | }
201 | },
202 | "node_modules/esbuild-linux-arm": {
203 | "version": "0.15.5",
204 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.5.tgz",
205 | "integrity": "sha512-wvAoHEN+gJ/22gnvhZnS/+2H14HyAxM07m59RSLn3iXrQsdS518jnEWRBnJz3fR6BJa+VUTo0NxYjGaNt7RA7Q==",
206 | "cpu": [
207 | "arm"
208 | ],
209 | "dev": true,
210 | "optional": true,
211 | "os": [
212 | "linux"
213 | ],
214 | "engines": {
215 | "node": ">=12"
216 | }
217 | },
218 | "node_modules/esbuild-linux-arm64": {
219 | "version": "0.15.5",
220 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.5.tgz",
221 | "integrity": "sha512-7EgFyP2zjO065XTfdCxiXVEk+f83RQ1JsryN1X/VSX2li9rnHAt2swRbpoz5Vlrl6qjHrCmq5b6yxD13z6RheA==",
222 | "cpu": [
223 | "arm64"
224 | ],
225 | "dev": true,
226 | "optional": true,
227 | "os": [
228 | "linux"
229 | ],
230 | "engines": {
231 | "node": ">=12"
232 | }
233 | },
234 | "node_modules/esbuild-linux-mips64le": {
235 | "version": "0.15.5",
236 | "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.5.tgz",
237 | "integrity": "sha512-KdnSkHxWrJ6Y40ABu+ipTZeRhFtc8dowGyFsZY5prsmMSr1ZTG9zQawguN4/tunJ0wy3+kD54GaGwdcpwWAvZQ==",
238 | "cpu": [
239 | "mips64el"
240 | ],
241 | "dev": true,
242 | "optional": true,
243 | "os": [
244 | "linux"
245 | ],
246 | "engines": {
247 | "node": ">=12"
248 | }
249 | },
250 | "node_modules/esbuild-linux-ppc64le": {
251 | "version": "0.15.5",
252 | "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.5.tgz",
253 | "integrity": "sha512-QdRHGeZ2ykl5P0KRmfGBZIHmqcwIsUKWmmpZTOq573jRWwmpfRmS7xOhmDHBj9pxv+6qRMH8tLr2fe+ZKQvCYw==",
254 | "cpu": [
255 | "ppc64"
256 | ],
257 | "dev": true,
258 | "optional": true,
259 | "os": [
260 | "linux"
261 | ],
262 | "engines": {
263 | "node": ">=12"
264 | }
265 | },
266 | "node_modules/esbuild-linux-riscv64": {
267 | "version": "0.15.5",
268 | "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.5.tgz",
269 | "integrity": "sha512-p+WE6RX+jNILsf+exR29DwgV6B73khEQV0qWUbzxaycxawZ8NE0wA6HnnTxbiw5f4Gx9sJDUBemh9v49lKOORA==",
270 | "cpu": [
271 | "riscv64"
272 | ],
273 | "dev": true,
274 | "optional": true,
275 | "os": [
276 | "linux"
277 | ],
278 | "engines": {
279 | "node": ">=12"
280 | }
281 | },
282 | "node_modules/esbuild-linux-s390x": {
283 | "version": "0.15.5",
284 | "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.5.tgz",
285 | "integrity": "sha512-J2ngOB4cNzmqLHh6TYMM/ips8aoZIuzxJnDdWutBw5482jGXiOzsPoEF4j2WJ2mGnm7FBCO4StGcwzOgic70JQ==",
286 | "cpu": [
287 | "s390x"
288 | ],
289 | "dev": true,
290 | "optional": true,
291 | "os": [
292 | "linux"
293 | ],
294 | "engines": {
295 | "node": ">=12"
296 | }
297 | },
298 | "node_modules/esbuild-netbsd-64": {
299 | "version": "0.15.5",
300 | "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.5.tgz",
301 | "integrity": "sha512-MmKUYGDizYjFia0Rwt8oOgmiFH7zaYlsoQ3tIOfPxOqLssAsEgG0MUdRDm5lliqjiuoog8LyDu9srQk5YwWF3w==",
302 | "cpu": [
303 | "x64"
304 | ],
305 | "dev": true,
306 | "optional": true,
307 | "os": [
308 | "netbsd"
309 | ],
310 | "engines": {
311 | "node": ">=12"
312 | }
313 | },
314 | "node_modules/esbuild-openbsd-64": {
315 | "version": "0.15.5",
316 | "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.5.tgz",
317 | "integrity": "sha512-2mMFfkLk3oPWfopA9Plj4hyhqHNuGyp5KQyTT9Rc8hFd8wAn5ZrbJg+gNcLMo2yzf8Uiu0RT6G9B15YN9WQyMA==",
318 | "cpu": [
319 | "x64"
320 | ],
321 | "dev": true,
322 | "optional": true,
323 | "os": [
324 | "openbsd"
325 | ],
326 | "engines": {
327 | "node": ">=12"
328 | }
329 | },
330 | "node_modules/esbuild-sunos-64": {
331 | "version": "0.15.5",
332 | "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.5.tgz",
333 | "integrity": "sha512-2sIzhMUfLNoD+rdmV6AacilCHSxZIoGAU2oT7XmJ0lXcZWnCvCtObvO6D4puxX9YRE97GodciRGDLBaiC6x1SA==",
334 | "cpu": [
335 | "x64"
336 | ],
337 | "dev": true,
338 | "optional": true,
339 | "os": [
340 | "sunos"
341 | ],
342 | "engines": {
343 | "node": ">=12"
344 | }
345 | },
346 | "node_modules/esbuild-windows-32": {
347 | "version": "0.15.5",
348 | "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.5.tgz",
349 | "integrity": "sha512-e+duNED9UBop7Vnlap6XKedA/53lIi12xv2ebeNS4gFmu7aKyTrok7DPIZyU5w/ftHD4MUDs5PJUkQPP9xJRzg==",
350 | "cpu": [
351 | "ia32"
352 | ],
353 | "dev": true,
354 | "optional": true,
355 | "os": [
356 | "win32"
357 | ],
358 | "engines": {
359 | "node": ">=12"
360 | }
361 | },
362 | "node_modules/esbuild-windows-64": {
363 | "version": "0.15.5",
364 | "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.5.tgz",
365 | "integrity": "sha512-v+PjvNtSASHOjPDMIai9Yi+aP+Vwox+3WVdg2JB8N9aivJ7lyhp4NVU+J0MV2OkWFPnVO8AE/7xH+72ibUUEnw==",
366 | "cpu": [
367 | "x64"
368 | ],
369 | "dev": true,
370 | "optional": true,
371 | "os": [
372 | "win32"
373 | ],
374 | "engines": {
375 | "node": ">=12"
376 | }
377 | },
378 | "node_modules/esbuild-windows-arm64": {
379 | "version": "0.15.5",
380 | "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.5.tgz",
381 | "integrity": "sha512-Yz8w/D8CUPYstvVQujByu6mlf48lKmXkq6bkeSZZxTA626efQOJb26aDGLzmFWx6eg/FwrXgt6SZs9V8Pwy/aA==",
382 | "cpu": [
383 | "arm64"
384 | ],
385 | "dev": true,
386 | "optional": true,
387 | "os": [
388 | "win32"
389 | ],
390 | "engines": {
391 | "node": ">=12"
392 | }
393 | }
394 | },
395 | "dependencies": {
396 | "@esbuild/linux-loong64": {
397 | "version": "0.15.5",
398 | "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.5.tgz",
399 | "integrity": "sha512-UHkDFCfSGTuXq08oQltXxSZmH1TXyWsL+4QhZDWvvLl6mEJQqk3u7/wq1LjhrrAXYIllaTtRSzUXl4Olkf2J8A==",
400 | "dev": true,
401 | "optional": true
402 | },
403 | "@types/node": {
404 | "version": "18.7.13",
405 | "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
406 | "integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
407 | "dev": true
408 | },
409 | "esbuild": {
410 | "version": "0.15.5",
411 | "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.5.tgz",
412 | "integrity": "sha512-VSf6S1QVqvxfIsSKb3UKr3VhUCis7wgDbtF4Vd9z84UJr05/Sp2fRKmzC+CSPG/dNAPPJZ0BTBLTT1Fhd6N9Gg==",
413 | "dev": true,
414 | "requires": {
415 | "@esbuild/linux-loong64": "0.15.5",
416 | "esbuild-android-64": "0.15.5",
417 | "esbuild-android-arm64": "0.15.5",
418 | "esbuild-darwin-64": "0.15.5",
419 | "esbuild-darwin-arm64": "0.15.5",
420 | "esbuild-freebsd-64": "0.15.5",
421 | "esbuild-freebsd-arm64": "0.15.5",
422 | "esbuild-linux-32": "0.15.5",
423 | "esbuild-linux-64": "0.15.5",
424 | "esbuild-linux-arm": "0.15.5",
425 | "esbuild-linux-arm64": "0.15.5",
426 | "esbuild-linux-mips64le": "0.15.5",
427 | "esbuild-linux-ppc64le": "0.15.5",
428 | "esbuild-linux-riscv64": "0.15.5",
429 | "esbuild-linux-s390x": "0.15.5",
430 | "esbuild-netbsd-64": "0.15.5",
431 | "esbuild-openbsd-64": "0.15.5",
432 | "esbuild-sunos-64": "0.15.5",
433 | "esbuild-windows-32": "0.15.5",
434 | "esbuild-windows-64": "0.15.5",
435 | "esbuild-windows-arm64": "0.15.5"
436 | }
437 | },
438 | "esbuild-android-64": {
439 | "version": "0.15.5",
440 | "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.5.tgz",
441 | "integrity": "sha512-dYPPkiGNskvZqmIK29OPxolyY3tp+c47+Fsc2WYSOVjEPWNCHNyqhtFqQadcXMJDQt8eN0NMDukbyQgFcHquXg==",
442 | "dev": true,
443 | "optional": true
444 | },
445 | "esbuild-android-arm64": {
446 | "version": "0.15.5",
447 | "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.5.tgz",
448 | "integrity": "sha512-YyEkaQl08ze3cBzI/4Cm1S+rVh8HMOpCdq8B78JLbNFHhzi4NixVN93xDrHZLztlocEYqi45rHHCgA8kZFidFg==",
449 | "dev": true,
450 | "optional": true
451 | },
452 | "esbuild-darwin-64": {
453 | "version": "0.15.5",
454 | "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.5.tgz",
455 | "integrity": "sha512-Cr0iIqnWKx3ZTvDUAzG0H/u9dWjLE4c2gTtRLz4pqOBGjfjqdcZSfAObFzKTInLLSmD0ZV1I/mshhPoYSBMMCQ==",
456 | "dev": true,
457 | "optional": true
458 | },
459 | "esbuild-darwin-arm64": {
460 | "version": "0.15.5",
461 | "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.5.tgz",
462 | "integrity": "sha512-WIfQkocGtFrz7vCu44ypY5YmiFXpsxvz2xqwe688jFfSVCnUsCn2qkEVDo7gT8EpsLOz1J/OmqjExePL1dr1Kg==",
463 | "dev": true,
464 | "optional": true
465 | },
466 | "esbuild-freebsd-64": {
467 | "version": "0.15.5",
468 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.5.tgz",
469 | "integrity": "sha512-M5/EfzV2RsMd/wqwR18CELcenZ8+fFxQAAEO7TJKDmP3knhWSbD72ILzrXFMMwshlPAS1ShCZ90jsxkm+8FlaA==",
470 | "dev": true,
471 | "optional": true
472 | },
473 | "esbuild-freebsd-arm64": {
474 | "version": "0.15.5",
475 | "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.5.tgz",
476 | "integrity": "sha512-2JQQ5Qs9J0440F/n/aUBNvY6lTo4XP/4lt1TwDfHuo0DY3w5++anw+jTjfouLzbJmFFiwmX7SmUhMnysocx96w==",
477 | "dev": true,
478 | "optional": true
479 | },
480 | "esbuild-linux-32": {
481 | "version": "0.15.5",
482 | "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.5.tgz",
483 | "integrity": "sha512-gO9vNnIN0FTUGjvTFucIXtBSr1Woymmx/aHQtuU+2OllGU6YFLs99960UD4Dib1kFovVgs59MTXwpFdVoSMZoQ==",
484 | "dev": true,
485 | "optional": true
486 | },
487 | "esbuild-linux-64": {
488 | "version": "0.15.5",
489 | "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.5.tgz",
490 | "integrity": "sha512-ne0GFdNLsm4veXbTnYAWjbx3shpNKZJUd6XpNbKNUZaNllDZfYQt0/zRqOg0sc7O8GQ+PjSMv9IpIEULXVTVmg==",
491 | "dev": true,
492 | "optional": true
493 | },
494 | "esbuild-linux-arm": {
495 | "version": "0.15.5",
496 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.5.tgz",
497 | "integrity": "sha512-wvAoHEN+gJ/22gnvhZnS/+2H14HyAxM07m59RSLn3iXrQsdS518jnEWRBnJz3fR6BJa+VUTo0NxYjGaNt7RA7Q==",
498 | "dev": true,
499 | "optional": true
500 | },
501 | "esbuild-linux-arm64": {
502 | "version": "0.15.5",
503 | "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.5.tgz",
504 | "integrity": "sha512-7EgFyP2zjO065XTfdCxiXVEk+f83RQ1JsryN1X/VSX2li9rnHAt2swRbpoz5Vlrl6qjHrCmq5b6yxD13z6RheA==",
505 | "dev": true,
506 | "optional": true
507 | },
508 | "esbuild-linux-mips64le": {
509 | "version": "0.15.5",
510 | "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.5.tgz",
511 | "integrity": "sha512-KdnSkHxWrJ6Y40ABu+ipTZeRhFtc8dowGyFsZY5prsmMSr1ZTG9zQawguN4/tunJ0wy3+kD54GaGwdcpwWAvZQ==",
512 | "dev": true,
513 | "optional": true
514 | },
515 | "esbuild-linux-ppc64le": {
516 | "version": "0.15.5",
517 | "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.5.tgz",
518 | "integrity": "sha512-QdRHGeZ2ykl5P0KRmfGBZIHmqcwIsUKWmmpZTOq573jRWwmpfRmS7xOhmDHBj9pxv+6qRMH8tLr2fe+ZKQvCYw==",
519 | "dev": true,
520 | "optional": true
521 | },
522 | "esbuild-linux-riscv64": {
523 | "version": "0.15.5",
524 | "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.5.tgz",
525 | "integrity": "sha512-p+WE6RX+jNILsf+exR29DwgV6B73khEQV0qWUbzxaycxawZ8NE0wA6HnnTxbiw5f4Gx9sJDUBemh9v49lKOORA==",
526 | "dev": true,
527 | "optional": true
528 | },
529 | "esbuild-linux-s390x": {
530 | "version": "0.15.5",
531 | "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.5.tgz",
532 | "integrity": "sha512-J2ngOB4cNzmqLHh6TYMM/ips8aoZIuzxJnDdWutBw5482jGXiOzsPoEF4j2WJ2mGnm7FBCO4StGcwzOgic70JQ==",
533 | "dev": true,
534 | "optional": true
535 | },
536 | "esbuild-netbsd-64": {
537 | "version": "0.15.5",
538 | "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.5.tgz",
539 | "integrity": "sha512-MmKUYGDizYjFia0Rwt8oOgmiFH7zaYlsoQ3tIOfPxOqLssAsEgG0MUdRDm5lliqjiuoog8LyDu9srQk5YwWF3w==",
540 | "dev": true,
541 | "optional": true
542 | },
543 | "esbuild-openbsd-64": {
544 | "version": "0.15.5",
545 | "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.5.tgz",
546 | "integrity": "sha512-2mMFfkLk3oPWfopA9Plj4hyhqHNuGyp5KQyTT9Rc8hFd8wAn5ZrbJg+gNcLMo2yzf8Uiu0RT6G9B15YN9WQyMA==",
547 | "dev": true,
548 | "optional": true
549 | },
550 | "esbuild-sunos-64": {
551 | "version": "0.15.5",
552 | "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.5.tgz",
553 | "integrity": "sha512-2sIzhMUfLNoD+rdmV6AacilCHSxZIoGAU2oT7XmJ0lXcZWnCvCtObvO6D4puxX9YRE97GodciRGDLBaiC6x1SA==",
554 | "dev": true,
555 | "optional": true
556 | },
557 | "esbuild-windows-32": {
558 | "version": "0.15.5",
559 | "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.5.tgz",
560 | "integrity": "sha512-e+duNED9UBop7Vnlap6XKedA/53lIi12xv2ebeNS4gFmu7aKyTrok7DPIZyU5w/ftHD4MUDs5PJUkQPP9xJRzg==",
561 | "dev": true,
562 | "optional": true
563 | },
564 | "esbuild-windows-64": {
565 | "version": "0.15.5",
566 | "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.5.tgz",
567 | "integrity": "sha512-v+PjvNtSASHOjPDMIai9Yi+aP+Vwox+3WVdg2JB8N9aivJ7lyhp4NVU+J0MV2OkWFPnVO8AE/7xH+72ibUUEnw==",
568 | "dev": true,
569 | "optional": true
570 | },
571 | "esbuild-windows-arm64": {
572 | "version": "0.15.5",
573 | "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.5.tgz",
574 | "integrity": "sha512-Yz8w/D8CUPYstvVQujByu6mlf48lKmXkq6bkeSZZxTA626efQOJb26aDGLzmFWx6eg/FwrXgt6SZs9V8Pwy/aA==",
575 | "dev": true,
576 | "optional": true
577 | }
578 | }
579 | }
580 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fast-text-encoding",
3 | "version": "0.0.1",
4 | "private": "true",
5 | "description": "Build package for fast-text-encoding, should not be published",
6 | "main": "text.min.js",
7 | "repository": "https://github.com/samthor/fast-text-encoding.git",
8 | "author": "Sam Thorogood ",
9 | "license": "Apache-2.0",
10 | "scripts": {
11 | "build": "node ./build.js",
12 | "test": "node --test ./test.js"
13 | },
14 | "devDependencies": {
15 | "@types/node": "^18.7.13",
16 | "esbuild": "^0.15.5"
17 | },
18 | "type": "module"
19 | }
20 |
--------------------------------------------------------------------------------
/package/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fast-text-encoding",
3 | "version": "1.0.6",
4 | "description": "Fast polyfill for TextEncoder and TextDecoder, only supports utf-8",
5 | "main": "text.min.js",
6 | "repository": "https://github.com/samthor/fast-text-encoding.git",
7 | "author": "Sam Thorogood ",
8 | "license": "Apache-2.0"
9 | }
10 |
--------------------------------------------------------------------------------
/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -eu
4 |
5 | npm run build
6 | npm run test
7 | cp README.md LICENSE text.min.js* package/
8 | cd package/
9 | npm version patch
10 | npm publish --dry-run
11 |
--------------------------------------------------------------------------------
/src/buffer.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * @param {Uint8Array} bytes
4 | * @param {string} encoding
5 | * @return {string}
6 | */
7 | export function decodeBuffer(bytes, encoding) {
8 | /** @type {Buffer} */
9 | var b;
10 | if (bytes instanceof Buffer) {
11 | // @ts-ignore
12 | b = bytes;
13 | } else {
14 | b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
15 | }
16 | return b.toString(/** @type {BufferEncoding} */(encoding));
17 | }
18 |
19 |
20 | /**
21 | * @param {string} string
22 | * @return {Uint8Array}
23 | */
24 | export var encodeBuffer = (string) => Buffer.from(string);
25 |
--------------------------------------------------------------------------------
/src/lowlevel.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * @param {Uint8Array} bytes
4 | * @return {string}
5 | */
6 | export function decodeFallback(bytes) {
7 | var inputIndex = 0;
8 |
9 | // Create a working buffer for UTF-16 code points, but don't generate one
10 | // which is too large for small input sizes. UTF-8 to UCS-16 conversion is
11 | // going to be at most 1:1, if all code points are ASCII. The other extreme
12 | // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%
13 | // fewer entries in the output.
14 | var pendingSize = Math.min(256 * 256, bytes.length + 1);
15 | var pending = new Uint16Array(pendingSize);
16 | var chunks = [];
17 | var pendingIndex = 0;
18 |
19 | for (; ;) {
20 | var more = inputIndex < bytes.length;
21 |
22 | // If there's no more data or there'd be no room for two UTF-16 values,
23 | // create a chunk. This isn't done at the end by simply slicing the data
24 | // into equal sized chunks as we might hit a surrogate pair.
25 | if (!more || (pendingIndex >= pendingSize - 1)) {
26 | // nb. .apply and friends are *really slow*. Low-hanging fruit is to
27 | // expand this to literally pass pending[0], pending[1], ... etc, but
28 | // the output code expands pretty fast in this case.
29 | // These extra vars get compiled out: they're just to make TS happy.
30 | // Turns out you can pass an ArrayLike to .apply().
31 | var subarray = pending.subarray(0, pendingIndex);
32 | var arraylike = /** @type {number[]} */ (/** @type {unknown} */ (subarray));
33 | chunks.push(String.fromCharCode.apply(null, arraylike));
34 |
35 | if (!more) {
36 | return chunks.join('');
37 | }
38 |
39 | // Move the buffer forward and create another chunk.
40 | bytes = bytes.subarray(inputIndex);
41 | inputIndex = 0;
42 | pendingIndex = 0;
43 | }
44 |
45 | // The native TextDecoder will generate "REPLACEMENT CHARACTER" where the
46 | // input data is invalid. Here, we blindly parse the data even if it's
47 | // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.
48 |
49 | var byte1 = bytes[inputIndex++];
50 | if ((byte1 & 0x80) === 0) { // 1-byte or null
51 | pending[pendingIndex++] = byte1;
52 | } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte
53 | var byte2 = bytes[inputIndex++] & 0x3f;
54 | pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;
55 | } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte
56 | var byte2 = bytes[inputIndex++] & 0x3f;
57 | var byte3 = bytes[inputIndex++] & 0x3f;
58 | pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;
59 | } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte
60 | var byte2 = bytes[inputIndex++] & 0x3f;
61 | var byte3 = bytes[inputIndex++] & 0x3f;
62 | var byte4 = bytes[inputIndex++] & 0x3f;
63 |
64 | // this can be > 0xffff, so possibly generate surrogates
65 | var codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
66 | if (codepoint > 0xffff) {
67 | // codepoint &= ~0x10000;
68 | codepoint -= 0x10000;
69 | pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;
70 | codepoint = 0xdc00 | codepoint & 0x3ff;
71 | }
72 | pending[pendingIndex++] = codepoint;
73 | } else {
74 | // invalid initial byte
75 | }
76 | }
77 | }
78 |
79 |
80 | /**
81 | * @param {string} string
82 | * @return {Uint8Array}
83 | */
84 | export function encodeFallback(string) {
85 | var pos = 0;
86 | var len = string.length;
87 |
88 | var at = 0; // output position
89 | var tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size
90 | var target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset
91 |
92 | while (pos < len) {
93 | var value = string.charCodeAt(pos++);
94 | if (value >= 0xd800 && value <= 0xdbff) {
95 | // high surrogate
96 | if (pos < len) {
97 | var extra = string.charCodeAt(pos);
98 | if ((extra & 0xfc00) === 0xdc00) {
99 | ++pos;
100 | value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
101 | }
102 | }
103 | if (value >= 0xd800 && value <= 0xdbff) {
104 | continue; // drop lone surrogate
105 | }
106 | }
107 |
108 | // expand the buffer if we couldn't write 4 bytes
109 | if (at + 4 > target.length) {
110 | tlen += 8; // minimum extra
111 | tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining
112 | tlen = (tlen >>> 3) << 3; // 8 byte offset
113 |
114 | var update = new Uint8Array(tlen);
115 | update.set(target);
116 | target = update;
117 | }
118 |
119 | if ((value & 0xffffff80) === 0) { // 1-byte
120 | target[at++] = value; // ASCII
121 | continue;
122 | } else if ((value & 0xfffff800) === 0) { // 2-byte
123 | target[at++] = ((value >>> 6) & 0x1f) | 0xc0;
124 | } else if ((value & 0xffff0000) === 0) { // 3-byte
125 | target[at++] = ((value >>> 12) & 0x0f) | 0xe0;
126 | target[at++] = ((value >>> 6) & 0x3f) | 0x80;
127 | } else if ((value & 0xffe00000) === 0) { // 4-byte
128 | target[at++] = ((value >>> 18) & 0x07) | 0xf0;
129 | target[at++] = ((value >>> 12) & 0x3f) | 0x80;
130 | target[at++] = ((value >>> 6) & 0x3f) | 0x80;
131 | } else {
132 | continue; // out of range
133 | }
134 |
135 | target[at++] = (value & 0x3f) | 0x80;
136 | }
137 |
138 | // Use subarray if slice isn't supported (IE11). This will use more memory
139 | // because the original array still exists.
140 | return target.slice ? target.slice(0, at) : target.subarray(0, at);
141 | }
142 |
--------------------------------------------------------------------------------
/src/o-decoder.js:
--------------------------------------------------------------------------------
1 | import { decodeBuffer } from './buffer.js';
2 | import { decodeFallback } from './lowlevel.js';
3 | import { failedToString, maybeThrowFailedToOption } from './shared.js';
4 | import { hasBufferFrom } from './support.js';
5 | import { decodeSyncXHR } from './xhr.js';
6 |
7 | var trySyncXHR = !hasBufferFrom && (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function');
8 | var validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];
9 |
10 | /** @type {(bytes: Uint8Array, encoding: string) => string} */
11 | var decodeImpl = decodeFallback;
12 | if (hasBufferFrom) {
13 | decodeImpl = decodeBuffer;
14 | } else if (trySyncXHR) {
15 | decodeImpl = (string) => {
16 | try {
17 | return decodeSyncXHR(string);
18 | } catch (e) {
19 | return decodeFallback(string);
20 | }
21 | };
22 | }
23 |
24 |
25 | var ctorString = `construct 'TextDecoder'`;
26 | var errorPrefix = `${failedToString} ${ctorString}: the `;
27 |
28 |
29 | /**
30 | * @constructor
31 | * @param {string=} utfLabel
32 | * @param {{fatal: boolean}=} options
33 | */
34 | export function FastTextDecoder(utfLabel, options) {
35 | maybeThrowFailedToOption(options && options.fatal, ctorString, 'fatal');
36 |
37 | utfLabel = utfLabel || 'utf-8';
38 |
39 | /** @type {boolean} */
40 | var ok;
41 | if (hasBufferFrom) {
42 | ok = Buffer.isEncoding(utfLabel);
43 | } else {
44 | ok = validUtfLabels.indexOf(utfLabel.toLowerCase()) !== -1;
45 | }
46 | if (!ok) {
47 | throw new RangeError(`${errorPrefix} encoding label provided ('${utfLabel}') is invalid.`);
48 | }
49 |
50 | this.encoding = utfLabel;
51 | this.fatal = false;
52 | this.ignoreBOM = false;
53 | }
54 |
55 | /**
56 | * @param {(ArrayBuffer|ArrayBufferView)} buffer
57 | * @param {{stream: boolean}=} options
58 | * @return {string}
59 | */
60 | FastTextDecoder.prototype.decode = function (buffer, options) {
61 | maybeThrowFailedToOption(options && options.stream, 'decode', 'stream');
62 |
63 | var bytes;
64 |
65 | if (buffer instanceof Uint8Array) {
66 | // Accept Uint8Array instances as-is. This is also a Node buffer.
67 | bytes = buffer;
68 | } else if (buffer['buffer'] instanceof ArrayBuffer) {
69 | // Look for ArrayBufferView, which isn't a real type, but basically
70 | // represents all the valid TypedArray types plus DataView. They all have
71 | // ".buffer" as an instance of ArrayBuffer.
72 | bytes = new Uint8Array(/** @type {ArrayBufferView} */(buffer).buffer);
73 | } else {
74 | // The only other valid argument here is that "buffer" is an ArrayBuffer.
75 | // We also try to convert anything else passed to a Uint8Array, as this
76 | // catches anything that's array-like. Native code would throw here.
77 | bytes = new Uint8Array(/** @type {any} */(buffer));
78 | }
79 |
80 | return decodeImpl(bytes, this.encoding);
81 | };
82 |
--------------------------------------------------------------------------------
/src/o-encoder.js:
--------------------------------------------------------------------------------
1 | import { encodeBuffer } from './buffer.js';
2 | import { encodeFallback } from './lowlevel.js';
3 | import { maybeThrowFailedToOption } from './shared.js';
4 | import { hasBufferFrom } from './support.js';
5 |
6 | export var encodeImpl = hasBufferFrom ? encodeBuffer : encodeFallback;
7 |
8 | /**
9 | * @constructor
10 | */
11 | export function FastTextEncoder() {
12 | // This does not accept an encoding, and always uses UTF-8:
13 | // https://www.w3.org/TR/encoding/#dom-textencoder
14 | this.encoding = 'utf-8';
15 | }
16 |
17 | /**
18 | * @param {string} string
19 | * @param {{stream: boolean}=} options
20 | * @return {Uint8Array}
21 | */
22 | FastTextEncoder.prototype.encode = function (string, options) {
23 | maybeThrowFailedToOption(options && options.stream, 'encode', 'stream');
24 | return encodeImpl(string);
25 | };
26 |
--------------------------------------------------------------------------------
/src/polyfill.js:
--------------------------------------------------------------------------------
1 |
2 | import { FastTextEncoder } from './o-encoder.js';
3 | import { FastTextDecoder } from './o-decoder.js';
4 |
5 | // /** @type {object} */
6 | // const scope = typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this);
7 |
8 | scope['TextEncoder'] = scope['TextEncoder'] || FastTextEncoder;
9 | scope['TextDecoder'] = scope['TextDecoder'] || FastTextDecoder;
10 |
11 | // export {};
12 |
--------------------------------------------------------------------------------
/src/shared.js:
--------------------------------------------------------------------------------
1 |
2 | export var failedToString = 'Failed to ';
3 |
4 | /**
5 | * @param {boolean|undefined} check
6 | * @param {string} operation
7 | * @param {string} fieldName
8 | */
9 | export var maybeThrowFailedToOption = (check, operation, fieldName) => {
10 | if (check) {
11 | throw new Error(`${failedToString}${operation}: the '${fieldName}' option is unsupported.`);
12 | }
13 | };
--------------------------------------------------------------------------------
/src/support.js:
--------------------------------------------------------------------------------
1 |
2 | export var hasBufferFrom = (typeof Buffer === 'function' && Buffer.from);
--------------------------------------------------------------------------------
/src/xhr.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * This is a horrible hack which works in some old browsers. We can tell them to decode bytes via
4 | * sync XHR.
5 | *
6 | * Throws if fails. Should be wrapped in something to check that.
7 | *
8 | * @param {Uint8Array} bytes
9 | * @return {string}
10 | */
11 | export function decodeSyncXHR(bytes) {
12 | var u;
13 |
14 | // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and
15 | // possibly in other places), so ensure there's a fallback call.
16 | try {
17 | var b = new Blob([bytes], { type: 'text/plain;charset=UTF-8' });
18 | u = URL.createObjectURL(b);
19 |
20 | var x = new XMLHttpRequest();
21 | x.open('GET', u, false);
22 | x.send();
23 | return x.responseText;
24 | } finally {
25 | if (u) {
26 | URL.revokeObjectURL(u);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/test-setup.js:
--------------------------------------------------------------------------------
1 |
2 | if (typeof global === 'undefined') {
3 | var global = globalThis;
4 | }
5 |
6 | const NativeTextEncoder = global.TextEncoder;
7 | const NativeTextDecoder = global.TextDecoder;
8 |
9 | global.TextDecoder = null;
10 | global.TextEncoder = null;
11 |
12 | export { NativeTextEncoder, NativeTextDecoder };
13 |
--------------------------------------------------------------------------------
/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview Test runner inside a Node environment.
3 | */
4 |
5 | import {
6 | NativeTextEncoder,
7 | NativeTextDecoder,
8 | } from './test-setup.js';
9 |
10 | import './text.min.js';
11 |
12 | import { decodeFallback, encodeFallback } from './src/lowlevel.js';
13 |
14 | import test from 'node:test';
15 | import * as assert from 'node:assert';
16 |
17 | /**
18 | * @param {boolean} isNative
19 | * @param {typeof TextEncoder} TextEncoder
20 | * @param {typeof TextDecoder} TextDecoder
21 | */
22 | export async function tests(isNative, TextEncoder, TextDecoder) {
23 | const dec = new TextDecoder();
24 | const enc = new TextEncoder('utf-8');
25 |
26 | console.info('running', { isNative, TextEncoder, TextDecoder });
27 |
28 | await test(isNative ? 'native suite' : 'polyfill suite', async (c) => {
29 | const test = c.test.bind(c);
30 |
31 | await test('really large string', async () => {
32 | const chunks = new Array(64);
33 | for (let i = 0; i < chunks.length; ++i) {
34 | const s = new Array(65535).fill('x'.charCodeAt(0));
35 | chunks[i] = s;
36 | }
37 | const s = chunks.join('');
38 |
39 | const buffer = enc.encode(s);
40 | const out = dec.decode(buffer);
41 |
42 | assert.strictEqual(out, s);
43 | });
44 |
45 | await test('decoder', async (c) => {
46 | const test = c.test.bind(c);
47 |
48 | await test('basic', () => {
49 | const buffer = new Uint8Array([104, 101, 108, 108, 111]);
50 | assert.strictEqual(dec.decode(buffer), 'hello', 'directly Uint8Array');
51 | assert.strictEqual(dec.decode(buffer.buffer), 'hello', 'pass underlying ArrayBuffer');
52 | });
53 |
54 | await test('non-8 backing', () => {
55 | // If passed a Uint32Array, TextDecoder will still decode the real
56 | // underlying bytes. Source data must be aligned.
57 | const padded = new Uint8Array([104, 101, 108, 108, 111, 33, 46, 46]);
58 | const u32 = new Uint32Array(padded.buffer);
59 | assert.strictEqual(padded.length >> 2, u32.length, 'u32 must be 1/4 of real data');
60 | assert.strictEqual(dec.decode(u32), 'hello!..', 'pass Uint32Array');
61 | assert.strictEqual(dec.decode(u32.buffer), 'hello!..', 'pass Uint32Array\'s buffer');
62 |
63 | // Ensure that we don't parse larger typed arrays as uint8's. We expect
64 | // nulls here to pad out the remaining three bytes in every word.
65 | const u32raw = new Uint32Array([104, 105, 33, 46]);
66 | assert.strictEqual(dec.decode(u32raw), 'h\0\0\0i\0\0\0!\0\0\0.\0\0\0', 'u32 with nulls');
67 | });
68 |
69 | await test('arraylike', () => {
70 | const arr = [104, 101, 108, 108, 111];
71 |
72 | if (NativeTextEncoder === TextEncoder) {
73 | // Native can't take Array.
74 | assert.throws(() => dec.decode(arr));
75 | } else {
76 | // Polyfill can accept Array or array-like.
77 | assert.strictEqual(dec.decode(arr), 'hello', 'decode arraylike');
78 | }
79 | });
80 |
81 | await test('constructor', () => {
82 | assert.throws(() => {
83 | new TextDecoder('invalid');
84 | }, RangeError);
85 |
86 | if (!isNative) {
87 | assert.throws(() => {
88 | new TextDecoder('utf-8', { fatal: true });
89 | }, Error, 'unsupported', 'fatal is unsupported');
90 | }
91 | });
92 |
93 | await test('subarray', () => {
94 | const buffer = new Uint8Array([104, 101, 108, 108, 111]);
95 | const array = buffer.subarray(0, 4);
96 | assert.strictEqual(dec.decode(array), 'hell');
97 | });
98 |
99 | await test('null in middle', () => {
100 | const s = 'pad\x00pad';
101 | const buffer = new Uint8Array([112, 97, 100, 0, 112, 97, 100]);
102 | assert.deepEqual(dec.decode(buffer), s);
103 | });
104 |
105 | await test('null at ends', () => {
106 | const s = '\x00\x00?\x00\x00';
107 | const buffer = new Uint8Array([0, 0, 63, 0, 0]);
108 | assert.deepEqual(dec.decode(buffer), s);
109 | });
110 |
111 | // Since this is being run in Node, this should work.
112 | await test('nodejs encodings', () => {
113 | if (typeof window === 'undefined' && isNative) {
114 | new TextDecoder('utf-16le');
115 | } else {
116 | assert.throws(() => {
117 | new TextDecoder('utf-16le');
118 | });
119 | }
120 | });
121 |
122 | });
123 |
124 | await test('encoder', async (c) => {
125 | const test = c.test.bind(c);
126 |
127 | await test('basic', () => {
128 | const buffer = new Uint8Array([104, 101, 108, 108, 111]);
129 | assert.deepEqual(enc.encode('hello'), buffer);
130 | });
131 |
132 | await test('constructor', () => {
133 | const enc2 = new TextEncoder('literally anything can go here');
134 | const enc3 = new TextEncoder(new Object());
135 |
136 | // Despite having no difference in functionality, these should not be the
137 | // same object.
138 | assert.notEqual(enc, enc2);
139 | assert.notEqual(enc, enc3);
140 | });
141 |
142 | await test('ie11 .slice', () => {
143 | const originalSlice = Uint8Array.prototype.slice;
144 | try {
145 | Uint8Array.prototype.slice = null;
146 | assert.deepEqual(Uint8Array.prototype.slice, null);
147 |
148 | // Confirms that the method works even without .slice.
149 | const buffer = new Uint8Array([194, 161]);
150 | assert.deepEqual(enc.encode('¡'), buffer);
151 |
152 | } finally {
153 | Uint8Array.prototype.slice = originalSlice;
154 | }
155 | });
156 |
157 | await test('null in middle', () => {
158 | const s = 'pad\x00pad';
159 | const buffer = new Uint8Array([112, 97, 100, 0, 112, 97, 100]);
160 | assert.deepEqual(enc.encode(s), buffer);
161 | });
162 |
163 | await test('null at ends', () => {
164 | const s = '\x00\x00?\x00\x00';
165 | const buffer = new Uint8Array([0, 0, 63, 0, 0]);
166 | assert.deepEqual(enc.encode(s), buffer);
167 | });
168 |
169 | });
170 |
171 | });
172 |
173 | }
174 |
175 |
176 | await test('always lowlevel', () => {
177 | const src = 'hello there ƒåcé zing';
178 |
179 | const b = encodeFallback(src);
180 | const out = decodeFallback(b);
181 |
182 | assert.equal(src, out);
183 | });
184 |
185 |
186 |
187 |
188 | await tests(true, NativeTextEncoder, NativeTextDecoder);
189 | await tests(true, TextEncoder, TextDecoder);
190 |
191 | const originalBufferFrom = Buffer.from;
192 | let d;
193 | try {
194 | globalThis.scope = {};
195 | Buffer.from = null;
196 | d = await import('./src/polyfill.js');
197 | console.warn('got Buffer.from', Buffer.from);
198 | } finally {
199 | Buffer.from = originalBufferFrom;
200 | }
201 | await tests(false, globalThis.scope.TextEncoder, globalThis.scope.TextDecoder);
202 |
--------------------------------------------------------------------------------
/text.min.js:
--------------------------------------------------------------------------------
1 | (function(scope) {'use strict';
2 | function B(r,e){var f;return r instanceof Buffer?f=r:f=Buffer.from(r.buffer,r.byteOffset,r.byteLength),f.toString(e)}var w=function(r){return Buffer.from(r)};function h(r){for(var e=0,f=Math.min(256*256,r.length+1),n=new Uint16Array(f),i=[],o=0;;){var t=e=f-1){var s=n.subarray(0,o),m=s;if(i.push(String.fromCharCode.apply(null,m)),!t)return i.join("");r=r.subarray(e),e=0,o=0}var a=r[e++];if((a&128)===0)n[o++]=a;else if((a&224)===192){var d=r[e++]&63;n[o++]=(a&31)<<6|d}else if((a&240)===224){var d=r[e++]&63,l=r[e++]&63;n[o++]=(a&31)<<12|d<<6|l}else if((a&248)===240){var d=r[e++]&63,l=r[e++]&63,R=r[e++]&63,c=(a&7)<<18|d<<12|l<<6|R;c>65535&&(c-=65536,n[o++]=c>>>10&1023|55296,c=56320|c&1023),n[o++]=c}}}function F(r){for(var e=0,f=r.length,n=0,i=Math.max(32,f+(f>>>1)+7),o=new Uint8Array(i>>>3<<3);e=55296&&t<=56319){if(e=55296&&t<=56319)continue}if(n+4>o.length){i+=8,i*=1+e/r.length*2,i=i>>>3<<3;var m=new Uint8Array(i);m.set(o),o=m}if((t&4294967168)===0){o[n++]=t;continue}else if((t&4294965248)===0)o[n++]=t>>>6&31|192;else if((t&4294901760)===0)o[n++]=t>>>12&15|224,o[n++]=t>>>6&63|128;else if((t&4292870144)===0)o[n++]=t>>>18&7|240,o[n++]=t>>>12&63|128,o[n++]=t>>>6&63|128;else continue;o[n++]=t&63|128}return o.slice?o.slice(0,n):o.subarray(0,n)}var u="Failed to ",p=function(r,e,f){if(r)throw new Error("".concat(u).concat(e,": the '").concat(f,"' option is unsupported."))};var x=typeof Buffer=="function"&&Buffer.from;var A=x?w:F;function v(){this.encoding="utf-8"}v.prototype.encode=function(r,e){return p(e&&e.stream,"encode","stream"),A(r)};function U(r){var e;try{var f=new Blob([r],{type:"text/plain;charset=UTF-8"});e=URL.createObjectURL(f);var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(),n.responseText}finally{e&&URL.revokeObjectURL(e)}}var O=!x&&typeof Blob=="function"&&typeof URL=="function"&&typeof URL.createObjectURL=="function",S=["utf-8","utf8","unicode-1-1-utf-8"],T=h;x?T=B:O&&(T=function(r){try{return U(r)}catch(e){return h(r)}});var y="construct 'TextDecoder'",E="".concat(u," ").concat(y,": the ");function g(r,e){p(e&&e.fatal,y,"fatal"),r=r||"utf-8";var f;if(x?f=Buffer.isEncoding(r):f=S.indexOf(r.toLowerCase())!==-1,!f)throw new RangeError("".concat(E," encoding label provided ('").concat(r,"') is invalid."));this.encoding=r,this.fatal=!1,this.ignoreBOM=!1}g.prototype.decode=function(r,e){p(e&&e.stream,"decode","stream");var f;return r instanceof Uint8Array?f=r:r.buffer instanceof ArrayBuffer?f=new Uint8Array(r.buffer):f=new Uint8Array(r),T(f,this.encoding)};scope.TextEncoder=scope.TextEncoder||v;scope.TextDecoder=scope.TextDecoder||g;
3 | }(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));
4 |
--------------------------------------------------------------------------------
/text.min.js.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "sources": ["src/buffer.js", "src/lowlevel.js", "src/shared.js", "src/support.js", "src/o-encoder.js", "src/xhr.js", "src/o-decoder.js", "src/polyfill.js"],
4 | "sourcesContent": ["\n/**\n * @param {Uint8Array} bytes\n * @param {string} encoding\n * @return {string}\n */\nexport function decodeBuffer(bytes, encoding) {\n /** @type {Buffer} */\n var b;\n if (bytes instanceof Buffer) {\n // @ts-ignore\n b = bytes;\n } else {\n b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n }\n return b.toString(/** @type {BufferEncoding} */(encoding));\n}\n\n\n/**\n * @param {string} string\n * @return {Uint8Array}\n */\nexport var encodeBuffer = (string) => Buffer.from(string);\n", "\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nexport function decodeFallback(bytes) {\n var inputIndex = 0;\n\n // Create a working buffer for UTF-16 code points, but don't generate one\n // which is too large for small input sizes. UTF-8 to UCS-16 conversion is\n // going to be at most 1:1, if all code points are ASCII. The other extreme\n // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%\n // fewer entries in the output.\n var pendingSize = Math.min(256 * 256, bytes.length + 1);\n var pending = new Uint16Array(pendingSize);\n var chunks = [];\n var pendingIndex = 0;\n\n for (; ;) {\n var more = inputIndex < bytes.length;\n\n // If there's no more data or there'd be no room for two UTF-16 values,\n // create a chunk. This isn't done at the end by simply slicing the data\n // into equal sized chunks as we might hit a surrogate pair.\n if (!more || (pendingIndex >= pendingSize - 1)) {\n // nb. .apply and friends are *really slow*. Low-hanging fruit is to\n // expand this to literally pass pending[0], pending[1], ... etc, but\n // the output code expands pretty fast in this case.\n // These extra vars get compiled out: they're just to make TS happy.\n // Turns out you can pass an ArrayLike to .apply().\n var subarray = pending.subarray(0, pendingIndex);\n var arraylike = /** @type {number[]} */ (/** @type {unknown} */ (subarray));\n chunks.push(String.fromCharCode.apply(null, arraylike));\n\n if (!more) {\n return chunks.join('');\n }\n\n // Move the buffer forward and create another chunk.\n bytes = bytes.subarray(inputIndex);\n inputIndex = 0;\n pendingIndex = 0;\n }\n\n // The native TextDecoder will generate \"REPLACEMENT CHARACTER\" where the\n // input data is invalid. Here, we blindly parse the data even if it's\n // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.\n\n var byte1 = bytes[inputIndex++];\n if ((byte1 & 0x80) === 0) { // 1-byte or null\n pending[pendingIndex++] = byte1;\n } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;\n } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n var byte3 = bytes[inputIndex++] & 0x3f;\n pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;\n } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte\n var byte2 = bytes[inputIndex++] & 0x3f;\n var byte3 = bytes[inputIndex++] & 0x3f;\n var byte4 = bytes[inputIndex++] & 0x3f;\n\n // this can be > 0xffff, so possibly generate surrogates\n var codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;\n if (codepoint > 0xffff) {\n // codepoint &= ~0x10000;\n codepoint -= 0x10000;\n pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;\n codepoint = 0xdc00 | codepoint & 0x3ff;\n }\n pending[pendingIndex++] = codepoint;\n } else {\n // invalid initial byte\n }\n }\n}\n\n\n/**\n * @param {string} string\n * @return {Uint8Array}\n */\nexport function encodeFallback(string) {\n var pos = 0;\n var len = string.length;\n\n var at = 0; // output position\n var tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size\n var target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset\n\n while (pos < len) {\n var value = string.charCodeAt(pos++);\n if (value >= 0xd800 && value <= 0xdbff) {\n // high surrogate\n if (pos < len) {\n var extra = string.charCodeAt(pos);\n if ((extra & 0xfc00) === 0xdc00) {\n ++pos;\n value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;\n }\n }\n if (value >= 0xd800 && value <= 0xdbff) {\n continue; // drop lone surrogate\n }\n }\n\n // expand the buffer if we couldn't write 4 bytes\n if (at + 4 > target.length) {\n tlen += 8; // minimum extra\n tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining\n tlen = (tlen >>> 3) << 3; // 8 byte offset\n\n var update = new Uint8Array(tlen);\n update.set(target);\n target = update;\n }\n\n if ((value & 0xffffff80) === 0) { // 1-byte\n target[at++] = value; // ASCII\n continue;\n } else if ((value & 0xfffff800) === 0) { // 2-byte\n target[at++] = ((value >>> 6) & 0x1f) | 0xc0;\n } else if ((value & 0xffff0000) === 0) { // 3-byte\n target[at++] = ((value >>> 12) & 0x0f) | 0xe0;\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\n } else if ((value & 0xffe00000) === 0) { // 4-byte\n target[at++] = ((value >>> 18) & 0x07) | 0xf0;\n target[at++] = ((value >>> 12) & 0x3f) | 0x80;\n target[at++] = ((value >>> 6) & 0x3f) | 0x80;\n } else {\n continue; // out of range\n }\n\n target[at++] = (value & 0x3f) | 0x80;\n }\n\n // Use subarray if slice isn't supported (IE11). This will use more memory\n // because the original array still exists.\n return target.slice ? target.slice(0, at) : target.subarray(0, at);\n}\n", "\nexport var failedToString = 'Failed to ';\n\n/**\n * @param {boolean|undefined} check \n * @param {string} operation \n * @param {string} fieldName \n */\nexport var maybeThrowFailedToOption = (check, operation, fieldName) => {\n if (check) {\n throw new Error(`${failedToString}${operation}: the '${fieldName}' option is unsupported.`);\n }\n};", "\nexport var hasBufferFrom = (typeof Buffer === 'function' && Buffer.from);", "import { encodeBuffer } from './buffer.js';\nimport { encodeFallback } from './lowlevel.js';\nimport { maybeThrowFailedToOption } from './shared.js';\nimport { hasBufferFrom } from './support.js';\n\nexport var encodeImpl = hasBufferFrom ? encodeBuffer : encodeFallback;\n\n/**\n * @constructor\n */\nexport function FastTextEncoder() {\n // This does not accept an encoding, and always uses UTF-8:\n // https://www.w3.org/TR/encoding/#dom-textencoder\n this.encoding = 'utf-8';\n}\n\n/**\n * @param {string} string\n * @param {{stream: boolean}=} options\n * @return {Uint8Array}\n */\nFastTextEncoder.prototype.encode = function (string, options) {\n maybeThrowFailedToOption(options && options.stream, 'encode', 'stream');\n return encodeImpl(string);\n};\n", "\n/**\n * This is a horrible hack which works in some old browsers. We can tell them to decode bytes via\n * sync XHR.\n *\n * Throws if fails. Should be wrapped in something to check that.\n *\n * @param {Uint8Array} bytes\n * @return {string}\n */\nexport function decodeSyncXHR(bytes) {\n var u;\n\n // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and\n // possibly in other places), so ensure there's a fallback call.\n try {\n var b = new Blob([bytes], { type: 'text/plain;charset=UTF-8' });\n u = URL.createObjectURL(b);\n\n var x = new XMLHttpRequest();\n x.open('GET', u, false);\n x.send();\n return x.responseText;\n } finally {\n if (u) {\n URL.revokeObjectURL(u);\n }\n }\n}", "import { decodeBuffer } from './buffer.js';\nimport { decodeFallback } from './lowlevel.js';\nimport { failedToString, maybeThrowFailedToOption } from './shared.js';\nimport { hasBufferFrom } from './support.js';\nimport { decodeSyncXHR } from './xhr.js';\n\nvar trySyncXHR = !hasBufferFrom && (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function');\nvar validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];\n\n/** @type {(bytes: Uint8Array, encoding: string) => string} */\nvar decodeImpl = decodeFallback;\nif (hasBufferFrom) {\n decodeImpl = decodeBuffer;\n} else if (trySyncXHR) {\n decodeImpl = (string) => {\n try {\n return decodeSyncXHR(string);\n } catch (e) {\n return decodeFallback(string);\n }\n };\n}\n\n\nvar ctorString = `construct 'TextDecoder'`;\nvar errorPrefix = `${failedToString} ${ctorString}: the `;\n\n\n/**\n * @constructor\n * @param {string=} utfLabel\n * @param {{fatal: boolean}=} options\n */\nexport function FastTextDecoder(utfLabel, options) {\n maybeThrowFailedToOption(options && options.fatal, ctorString, 'fatal');\n\n utfLabel = utfLabel || 'utf-8';\n\n /** @type {boolean} */\n var ok;\n if (hasBufferFrom) {\n ok = Buffer.isEncoding(utfLabel);\n } else {\n ok = validUtfLabels.indexOf(utfLabel.toLowerCase()) !== -1;\n }\n if (!ok) {\n throw new RangeError(`${errorPrefix} encoding label provided ('${utfLabel}') is invalid.`);\n }\n\n this.encoding = utfLabel;\n this.fatal = false;\n this.ignoreBOM = false;\n}\n\n/**\n * @param {(ArrayBuffer|ArrayBufferView)} buffer\n * @param {{stream: boolean}=} options\n * @return {string}\n */\nFastTextDecoder.prototype.decode = function (buffer, options) {\n maybeThrowFailedToOption(options && options.stream, 'decode', 'stream');\n\n var bytes;\n\n if (buffer instanceof Uint8Array) {\n // Accept Uint8Array instances as-is. This is also a Node buffer.\n bytes = buffer;\n } else if (buffer['buffer'] instanceof ArrayBuffer) {\n // Look for ArrayBufferView, which isn't a real type, but basically\n // represents all the valid TypedArray types plus DataView. They all have\n // \".buffer\" as an instance of ArrayBuffer.\n bytes = new Uint8Array(/** @type {ArrayBufferView} */(buffer).buffer);\n } else {\n // The only other valid argument here is that \"buffer\" is an ArrayBuffer.\n // We also try to convert anything else passed to a Uint8Array, as this\n // catches anything that's array-like. Native code would throw here.\n bytes = new Uint8Array(/** @type {any} */(buffer));\n }\n\n return decodeImpl(bytes, this.encoding);\n};\n", "\nimport { FastTextEncoder } from './o-encoder.js';\nimport { FastTextDecoder } from './o-decoder.js';\n\n// /** @type {object} */\n// const scope = typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this);\n\nscope['TextEncoder'] = scope['TextEncoder'] || FastTextEncoder;\nscope['TextDecoder'] = scope['TextDecoder'] || FastTextDecoder;\n\n// export {};\n"],
5 | "mappings": ";AAMO,SAASA,EAAaC,EAAOC,EAAU,CAE5C,IAAIC,EACJ,OAAIF,aAAiB,OAEnBE,EAAIF,EAEJE,EAAI,OAAO,KAAKF,EAAM,OAAQA,EAAM,WAAYA,EAAM,UAAU,EAE3DE,EAAE,SAAuCD,CAAS,CAC3D,CAOO,IAAIE,EAAe,SAACC,EAAQ,CAAG,cAAO,KAAKA,CAAM,GClBjD,SAASC,EAAeC,EAAO,CAapC,QAZIC,EAAa,EAObC,EAAc,KAAK,IAAI,IAAM,IAAKF,EAAM,OAAS,CAAC,EAClDG,EAAU,IAAI,YAAYD,CAAW,EACrCE,EAAS,CAAC,EACVC,EAAe,IAET,CACR,IAAIC,EAAOL,EAAaD,EAAM,OAK9B,GAAI,CAACM,GAASD,GAAgBH,EAAc,EAAI,CAM9C,IAAIK,EAAWJ,EAAQ,SAAS,EAAGE,CAAY,EAC3CG,EAA6DD,EAGjE,GAFAH,EAAO,KAAK,OAAO,aAAa,MAAM,KAAMI,CAAS,CAAC,EAElD,CAACF,EACH,OAAOF,EAAO,KAAK,EAAE,EAIvBJ,EAAQA,EAAM,SAASC,CAAU,EACjCA,EAAa,EACbI,EAAe,CACjB,CAMA,IAAII,EAAQT,EAAMC,KAClB,IAAKQ,EAAQ,OAAU,EACrBN,EAAQE,KAAkBI,WAChBA,EAAQ,OAAU,IAAM,CAClC,IAAIC,EAAQV,EAAMC,KAAgB,GAClCE,EAAQE,MAAoBI,EAAQ,KAAS,EAAKC,CACpD,UAAYD,EAAQ,OAAU,IAAM,CAClC,IAAIC,EAAQV,EAAMC,KAAgB,GAC9BU,EAAQX,EAAMC,KAAgB,GAClCE,EAAQE,MAAoBI,EAAQ,KAAS,GAAOC,GAAS,EAAKC,CACpE,UAAYF,EAAQ,OAAU,IAAM,CAClC,IAAIC,EAAQV,EAAMC,KAAgB,GAC9BU,EAAQX,EAAMC,KAAgB,GAC9BW,EAAQZ,EAAMC,KAAgB,GAG9BY,GAAcJ,EAAQ,IAAS,GAASC,GAAS,GAASC,GAAS,EAAQC,EAC3EC,EAAY,QAEdA,GAAa,MACbV,EAAQE,KAAmBQ,IAAc,GAAM,KAAQ,MACvDA,EAAY,MAASA,EAAY,MAEnCV,EAAQE,KAAkBQ,CAC5B,CAGF,CACF,CAOO,SAASC,EAAeC,EAAQ,CAQrC,QAPIC,EAAM,EACNC,EAAMF,EAAO,OAEbG,EAAK,EACLC,EAAO,KAAK,IAAI,GAAIF,GAAOA,IAAQ,GAAK,CAAC,EACzCG,EAAS,IAAI,WAAYD,IAAS,GAAM,CAAC,EAEtCH,EAAMC,GAAK,CAChB,IAAII,EAAQN,EAAO,WAAWC,GAAK,EACnC,GAAIK,GAAS,OAAUA,GAAS,MAAQ,CAEtC,GAAIL,EAAMC,EAAK,CACb,IAAIK,EAAQP,EAAO,WAAWC,CAAG,GAC5BM,EAAQ,SAAY,QACvB,EAAEN,EACFK,IAAUA,EAAQ,OAAU,KAAOC,EAAQ,MAAS,MAExD,CACA,GAAID,GAAS,OAAUA,GAAS,MAC9B,QAEJ,CAGA,GAAIH,EAAK,EAAIE,EAAO,OAAQ,CAC1BD,GAAQ,EACRA,GAAS,EAAOH,EAAMD,EAAO,OAAU,EACvCI,EAAQA,IAAS,GAAM,EAEvB,IAAII,EAAS,IAAI,WAAWJ,CAAI,EAChCI,EAAO,IAAIH,CAAM,EACjBA,EAASG,CACX,CAEA,IAAKF,EAAQ,cAAgB,EAAG,CAC9BD,EAAOF,KAAQG,EACf,QACF,UAAYA,EAAQ,cAAgB,EAClCD,EAAOF,KAAUG,IAAU,EAAK,GAAQ,aAC9BA,EAAQ,cAAgB,EAClCD,EAAOF,KAAUG,IAAU,GAAM,GAAQ,IACzCD,EAAOF,KAAUG,IAAU,EAAK,GAAQ,aAC9BA,EAAQ,cAAgB,EAClCD,EAAOF,KAAUG,IAAU,GAAM,EAAQ,IACzCD,EAAOF,KAAUG,IAAU,GAAM,GAAQ,IACzCD,EAAOF,KAAUG,IAAU,EAAK,GAAQ,QAExC,UAGFD,EAAOF,KAASG,EAAQ,GAAQ,GAClC,CAIA,OAAOD,EAAO,MAAQA,EAAO,MAAM,EAAGF,CAAE,EAAIE,EAAO,SAAS,EAAGF,CAAE,CACnE,CC3IO,IAAIM,EAAiB,aAOjBC,EAA2B,SAACC,EAAOC,EAAWC,EAAc,CACrE,GAAIF,EACF,MAAM,IAAI,MAAM,GAAG,OAAAF,GAAiB,OAAAG,EAAS,WAAU,OAAAC,EAAS,2BAA0B,CAE9F,ECXO,IAAIC,EAAiB,OAAO,QAAW,YAAc,OAAO,KCI5D,IAAIC,EAAaC,EAAgBC,EAAeC,EAKhD,SAASC,GAAkB,CAGhC,KAAK,SAAW,OAClB,CAOAA,EAAgB,UAAU,OAAS,SAAUC,EAAQC,EAAS,CAC5D,OAAAC,EAAyBD,GAAWA,EAAQ,OAAQ,SAAU,QAAQ,EAC/DN,EAAWK,CAAM,CAC1B,ECdO,SAASG,EAAcC,EAAO,CACnC,IAAIC,EAIJ,GAAI,CACF,IAAIC,EAAI,IAAI,KAAK,CAACF,CAAK,EAAG,CAAE,KAAM,0BAA2B,CAAC,EAC9DC,EAAI,IAAI,gBAAgBC,CAAC,EAEzB,IAAIC,EAAI,IAAI,eACZ,OAAAA,EAAE,KAAK,MAAOF,EAAG,EAAK,EACtBE,EAAE,KAAK,EACAA,EAAE,YACX,QAAE,CACIF,GACF,IAAI,gBAAgBA,CAAC,CAEzB,CACF,CCtBA,IAAIG,EAAa,CAACC,GAAkB,OAAO,MAAS,YAAc,OAAO,KAAQ,YAAc,OAAO,IAAI,iBAAoB,WAC1HC,EAAiB,CAAC,QAAS,OAAQ,mBAAmB,EAGtDC,EAAaC,EACbH,EACFE,EAAaE,EACJL,IACTG,EAAa,SAACG,EAAW,CACvB,GAAI,CACF,OAAOC,EAAcD,CAAM,CAC7B,OAAS,EAAP,CACA,OAAOF,EAAeE,CAAM,CAC9B,CACF,GAIF,IAAIE,EAAa,0BACbC,EAAc,GAAG,OAAAC,EAAc,KAAI,OAAAF,EAAU,UAQ1C,SAASG,EAAgBC,EAAUC,EAAS,CACjDC,EAAyBD,GAAWA,EAAQ,MAAOL,EAAY,OAAO,EAEtEI,EAAWA,GAAY,QAGvB,IAAIG,EAMJ,GALId,EACFc,EAAK,OAAO,WAAWH,CAAQ,EAE/BG,EAAKb,EAAe,QAAQU,EAAS,YAAY,CAAC,IAAM,GAEtD,CAACG,EACH,MAAM,IAAI,WAAW,GAAG,OAAAN,EAAW,+BAA8B,OAAAG,EAAQ,iBAAgB,EAG3F,KAAK,SAAWA,EAChB,KAAK,MAAQ,GACb,KAAK,UAAY,EACnB,CAOAD,EAAgB,UAAU,OAAS,SAAUK,EAAQH,EAAS,CAC5DC,EAAyBD,GAAWA,EAAQ,OAAQ,SAAU,QAAQ,EAEtE,IAAII,EAEJ,OAAID,aAAkB,WAEpBC,EAAQD,EACCA,EAAO,kBAAqB,YAIrCC,EAAQ,IAAI,WAA0CD,EAAQ,MAAM,EAKpEC,EAAQ,IAAI,WAA8BD,CAAO,EAG5Cb,EAAWc,EAAO,KAAK,QAAQ,CACxC,ECzEA,MAAM,YAAiB,MAAM,aAAkBC,EAC/C,MAAM,YAAiB,MAAM,aAAkBC",
6 | "names": ["decodeBuffer", "bytes", "encoding", "b", "encodeBuffer", "string", "decodeFallback", "bytes", "inputIndex", "pendingSize", "pending", "chunks", "pendingIndex", "more", "subarray", "arraylike", "byte1", "byte2", "byte3", "byte4", "codepoint", "encodeFallback", "string", "pos", "len", "at", "tlen", "target", "value", "extra", "update", "failedToString", "maybeThrowFailedToOption", "check", "operation", "fieldName", "hasBufferFrom", "encodeImpl", "hasBufferFrom", "encodeBuffer", "encodeFallback", "FastTextEncoder", "string", "options", "maybeThrowFailedToOption", "decodeSyncXHR", "bytes", "u", "b", "x", "trySyncXHR", "hasBufferFrom", "validUtfLabels", "decodeImpl", "decodeFallback", "decodeBuffer", "string", "decodeSyncXHR", "ctorString", "errorPrefix", "failedToString", "FastTextDecoder", "utfLabel", "options", "maybeThrowFailedToOption", "ok", "buffer", "bytes", "FastTextEncoder", "FastTextDecoder"]
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "checkJs": true,
4 | "noEmit": true,
5 |
6 | // if you'd like to warn if you're using modern features, change these
7 | // both to e.g., "es2017"
8 | "module": "esnext",
9 | "target": "esnext",
10 | "moduleResolution": "node",
11 |
12 | // configure as you like: these are my preferred defaults!
13 | "strict": true,
14 | "skipLibCheck": true,
15 | "forceConsistentCasingInFileNames": true,
16 |
17 | // "strict" implies this, but you'll want to enable it when you're
18 | // ready: it's a huge reason your project will start complaining
19 | "noImplicitAny": false,
20 | },
21 | "include": [
22 | // include the JS files you'd like to check here
23 | "src/**/*.js",
24 | "*.js",
25 | ],
26 | }
--------------------------------------------------------------------------------