diff --git a/README.md b/README.md
index 31e1d97..e11fdd7 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,15 @@
This is a fast polyfill for [`TextEncoder`][1] and [`TextDecoder`][2], which let you encode and decode JavaScript strings into UTF-8 bytes.
-It is fast partially as it does not support any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
+It is fast partially as it does not support^ any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
See [some benchmarks](https://github.com/samthor/fast-text-encoding/tree/master/bench).
+
+
+^If this is run on Node v5.1 through v11 (when `Text...` was introduced), then this simply wraps `Buffer`, which supports many encodings and is native code.
+
+
+
[1]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
[2]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
diff --git a/compile.sh b/compile.sh
deleted file mode 100755
index b8d83ef..0000000
--- a/compile.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env sh
-
-google-closure-compiler \
- --compilation_level ADVANCED \
- --js_output_file text.min.js \
- --language_out ECMASCRIPT5 \
- --warning_level VERBOSE \
- --create_source_map %outname%.map \
- --externs externs.js \
- text.js
diff --git a/externs.js b/externs.js
deleted file mode 100644
index acf27c5..0000000
--- a/externs.js
+++ /dev/null
@@ -1,20 +0,0 @@
-
-/**
- * @constructor
- */
-var Buffer;
-
-/**
- * @param {!ArrayBuffer} raw
- * @param {number} byteOffset
- * @param {number} byteLength
- * @return {!Buffer}
- */
-Buffer.from = function(raw, byteOffset, byteLength) {};
-
-/**
- * @this {*}
- * @param {string} encoding
- * @return {string}
- */
-Buffer.prototype.toString = function(encoding) {};
diff --git a/package-lock.json b/package-lock.json
index f7c6751..1c9235b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,8 +10,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^18.7.13",
- "esbuild": "^0.15.5",
- "google-closure-compiler": "^20220601.0.0"
+ "esbuild": "^0.15.5"
}
},
"node_modules/@esbuild/linux-loong64": {
@@ -36,88 +35,6 @@
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
"dev": true
},
- "node_modules/ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
- "dev": true,
- "dependencies": {
- "color-convert": "^1.9.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dev": true,
- "dependencies": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/clone": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
- "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
- "dev": true,
- "engines": {
- "node": ">=0.8"
- }
- },
- "node_modules/clone-buffer": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
- "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg= sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g==",
- "dev": true,
- "engines": {
- "node": ">= 0.10"
- }
- },
- "node_modules/clone-stats": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
- "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= sha512-au6ydSpg6nsrigcZ4m8Bc9hxjeW+GJ8xh5G3BJCMt4WXe1H10UNaVOamqQTmrx1kjVuxAHIQSNU6hY4Nsn9/ag==",
- "dev": true
- },
- "node_modules/cloneable-readable": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz",
- "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==",
- "dev": true,
- "dependencies": {
- "inherits": "^2.0.1",
- "process-nextick-args": "^2.0.0",
- "readable-stream": "^2.3.5"
- }
- },
- "node_modules/color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
- "dev": true,
- "dependencies": {
- "color-name": "1.1.3"
- }
- },
- "node_modules/color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
- "dev": true
- },
- "node_modules/core-util-is": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
- "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==",
- "dev": true
- },
"node_modules/esbuild": {
"version": "0.15.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.5.tgz",
@@ -473,218 +390,6 @@
"engines": {
"node": ">=12"
}
- },
- "node_modules/escape-string-regexp": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
- "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
- "dev": true,
- "engines": {
- "node": ">=0.8.0"
- }
- },
- "node_modules/google-closure-compiler": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20220601.0.0.tgz",
- "integrity": "sha512-bK0nEtDoQ8WcAtGtEhWu/+OEyzmNp9yCMFc5jLeOajoUuclHWxbjMeJ2eHyMPvvuvoLprollVapyQSAlO+dMIw==",
- "dev": true,
- "dependencies": {
- "chalk": "2.x",
- "google-closure-compiler-java": "^20220601.0.0",
- "minimist": "1.x",
- "vinyl": "2.x",
- "vinyl-sourcemaps-apply": "^0.2.0"
- },
- "bin": {
- "google-closure-compiler": "cli.js"
- },
- "engines": {
- "node": ">=10"
- },
- "optionalDependencies": {
- "google-closure-compiler-linux": "^20220601.0.0",
- "google-closure-compiler-osx": "^20220601.0.0",
- "google-closure-compiler-windows": "^20220601.0.0"
- }
- },
- "node_modules/google-closure-compiler-java": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20220601.0.0.tgz",
- "integrity": "sha512-PMlzO2SbwKEm+V3xxigVYqa51e7XPnfsf4VAXS4Bx43ol6xkZnPTgZchGIfxDOMYOch2WlGMY8+/QDEluR/7DQ==",
- "dev": true
- },
- "node_modules/google-closure-compiler-linux": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20220601.0.0.tgz",
- "integrity": "sha512-ZhEzQ4oCAkbVimkeL84ec+hC1Olcy9dq97q7RhHoSQf4o/oDvEFbIfbeL5tHvIQlv3Ez+TkhRHXvnxam8MYw2Q==",
- "cpu": [
- "x64",
- "x86"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "linux"
- ]
- },
- "node_modules/google-closure-compiler-osx": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20220601.0.0.tgz",
- "integrity": "sha512-0fhGb08xiSVFzRnC7DUz9v4WfouIWu/GozSAUbDx/u6TnQvkz0ImQTOis37BzgRHoWMQ+1JTwYndRww23JuBWQ==",
- "cpu": [
- "x64",
- "x86",
- "arm64"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "darwin"
- ]
- },
- "node_modules/google-closure-compiler-windows": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20220601.0.0.tgz",
- "integrity": "sha512-AhZrbTjP2qfltibrFyZ8j4ZAYuqKVks6XUnqaYaXvF1bhwS16hkJC4ZkSxWiLMHTgnUu0lqUIy4FwuEWlTMN1g==",
- "cpu": [
- "x64"
- ],
- "dev": true,
- "optional": true,
- "os": [
- "win32"
- ]
- },
- "node_modules/has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0= sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
- "dev": true,
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/inherits": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
- "dev": true
- },
- "node_modules/isarray": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
- "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
- "dev": true
- },
- "node_modules/minimist": {
- "version": "1.2.6",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
- "dev": true
- },
- "node_modules/process-nextick-args": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
- "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
- "dev": true
- },
- "node_modules/readable-stream": {
- "version": "2.3.7",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
- "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
- "dev": true,
- "dependencies": {
- "core-util-is": "~1.0.0",
- "inherits": "~2.0.3",
- "isarray": "~1.0.0",
- "process-nextick-args": "~2.0.0",
- "safe-buffer": "~5.1.1",
- "string_decoder": "~1.1.1",
- "util-deprecate": "~1.0.1"
- }
- },
- "node_modules/remove-trailing-separator": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
- "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8= sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==",
- "dev": true
- },
- "node_modules/replace-ext": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
- "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= sha512-vuNYXC7gG7IeVNBC1xUllqCcZKRbJoSPOBhnTEcAIiKCsbuef6zO3F0Rve3isPMMoNoQRWjQwbAgAjHUHniyEA==",
- "dev": true,
- "engines": {
- "node": ">= 0.10"
- }
- },
- "node_modules/safe-buffer": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
- "dev": true
- },
- "node_modules/source-map": {
- "version": "0.5.7",
- "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
- "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==",
- "dev": true,
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/string_decoder": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
- "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
- "dev": true,
- "dependencies": {
- "safe-buffer": "~5.1.0"
- }
- },
- "node_modules/supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
- "dev": true,
- "dependencies": {
- "has-flag": "^3.0.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/util-deprecate": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
- "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
- "dev": true
- },
- "node_modules/vinyl": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
- "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
- "dev": true,
- "dependencies": {
- "clone": "^2.1.1",
- "clone-buffer": "^1.0.0",
- "clone-stats": "^1.0.0",
- "cloneable-readable": "^1.0.0",
- "remove-trailing-separator": "^1.0.1",
- "replace-ext": "^1.0.0"
- },
- "engines": {
- "node": ">= 0.10"
- }
- },
- "node_modules/vinyl-sourcemaps-apply": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz",
- "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU= sha512-+oDh3KYZBoZC8hfocrbrxbLUeaYtQK7J5WU5Br9VqWqmCll3tFJqKp97GC9GmMsVIL0qnx2DgEDVxdo5EZ5sSw==",
- "dev": true,
- "dependencies": {
- "source-map": "^0.5.1"
- }
}
},
"dependencies": {
@@ -701,76 +406,6 @@
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
"dev": true
},
- "ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
- "dev": true,
- "requires": {
- "color-convert": "^1.9.0"
- }
- },
- "chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dev": true,
- "requires": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- }
- },
- "clone": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
- "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
- "dev": true
- },
- "clone-buffer": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
- "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg= sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g==",
- "dev": true
- },
- "clone-stats": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
- "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= sha512-au6ydSpg6nsrigcZ4m8Bc9hxjeW+GJ8xh5G3BJCMt4WXe1H10UNaVOamqQTmrx1kjVuxAHIQSNU6hY4Nsn9/ag==",
- "dev": true
- },
- "cloneable-readable": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.3.tgz",
- "integrity": "sha512-2EF8zTQOxYq70Y4XKtorQupqF0m49MBz2/yf5Bj+MHjvpG3Hy7sImifnqD6UA+TKYxeSV+u6qqQPawN5UvnpKQ==",
- "dev": true,
- "requires": {
- "inherits": "^2.0.1",
- "process-nextick-args": "^2.0.0",
- "readable-stream": "^2.3.5"
- }
- },
- "color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
- "dev": true,
- "requires": {
- "color-name": "1.1.3"
- }
- },
- "color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
- "dev": true
- },
- "core-util-is": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
- "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==",
- "dev": true
- },
"esbuild": {
"version": "0.15.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.5.tgz",
@@ -939,171 +574,6 @@
"integrity": "sha512-Yz8w/D8CUPYstvVQujByu6mlf48lKmXkq6bkeSZZxTA626efQOJb26aDGLzmFWx6eg/FwrXgt6SZs9V8Pwy/aA==",
"dev": true,
"optional": true
- },
- "escape-string-regexp": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
- "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
- "dev": true
- },
- "google-closure-compiler": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20220601.0.0.tgz",
- "integrity": "sha512-bK0nEtDoQ8WcAtGtEhWu/+OEyzmNp9yCMFc5jLeOajoUuclHWxbjMeJ2eHyMPvvuvoLprollVapyQSAlO+dMIw==",
- "dev": true,
- "requires": {
- "chalk": "2.x",
- "google-closure-compiler-java": "^20220601.0.0",
- "google-closure-compiler-linux": "^20220601.0.0",
- "google-closure-compiler-osx": "^20220601.0.0",
- "google-closure-compiler-windows": "^20220601.0.0",
- "minimist": "1.x",
- "vinyl": "2.x",
- "vinyl-sourcemaps-apply": "^0.2.0"
- }
- },
- "google-closure-compiler-java": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20220601.0.0.tgz",
- "integrity": "sha512-PMlzO2SbwKEm+V3xxigVYqa51e7XPnfsf4VAXS4Bx43ol6xkZnPTgZchGIfxDOMYOch2WlGMY8+/QDEluR/7DQ==",
- "dev": true
- },
- "google-closure-compiler-linux": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20220601.0.0.tgz",
- "integrity": "sha512-ZhEzQ4oCAkbVimkeL84ec+hC1Olcy9dq97q7RhHoSQf4o/oDvEFbIfbeL5tHvIQlv3Ez+TkhRHXvnxam8MYw2Q==",
- "dev": true,
- "optional": true
- },
- "google-closure-compiler-osx": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20220601.0.0.tgz",
- "integrity": "sha512-0fhGb08xiSVFzRnC7DUz9v4WfouIWu/GozSAUbDx/u6TnQvkz0ImQTOis37BzgRHoWMQ+1JTwYndRww23JuBWQ==",
- "dev": true,
- "optional": true
- },
- "google-closure-compiler-windows": {
- "version": "20220601.0.0",
- "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20220601.0.0.tgz",
- "integrity": "sha512-AhZrbTjP2qfltibrFyZ8j4ZAYuqKVks6XUnqaYaXvF1bhwS16hkJC4ZkSxWiLMHTgnUu0lqUIy4FwuEWlTMN1g==",
- "dev": true,
- "optional": true
- },
- "has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0= sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
- "dev": true
- },
- "inherits": {
- "version": "2.0.4",
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
- "dev": true
- },
- "isarray": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
- "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
- "dev": true
- },
- "minimist": {
- "version": "1.2.6",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
- "dev": true
- },
- "process-nextick-args": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
- "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
- "dev": true
- },
- "readable-stream": {
- "version": "2.3.7",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
- "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
- "dev": true,
- "requires": {
- "core-util-is": "~1.0.0",
- "inherits": "~2.0.3",
- "isarray": "~1.0.0",
- "process-nextick-args": "~2.0.0",
- "safe-buffer": "~5.1.1",
- "string_decoder": "~1.1.1",
- "util-deprecate": "~1.0.1"
- }
- },
- "remove-trailing-separator": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
- "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8= sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==",
- "dev": true
- },
- "replace-ext": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
- "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= sha512-vuNYXC7gG7IeVNBC1xUllqCcZKRbJoSPOBhnTEcAIiKCsbuef6zO3F0Rve3isPMMoNoQRWjQwbAgAjHUHniyEA==",
- "dev": true
- },
- "safe-buffer": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
- "dev": true
- },
- "source-map": {
- "version": "0.5.7",
- "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
- "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==",
- "dev": true
- },
- "string_decoder": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
- "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
- "dev": true,
- "requires": {
- "safe-buffer": "~5.1.0"
- }
- },
- "supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
- "dev": true,
- "requires": {
- "has-flag": "^3.0.0"
- }
- },
- "util-deprecate": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
- "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
- "dev": true
- },
- "vinyl": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
- "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
- "dev": true,
- "requires": {
- "clone": "^2.1.1",
- "clone-buffer": "^1.0.0",
- "clone-stats": "^1.0.0",
- "cloneable-readable": "^1.0.0",
- "remove-trailing-separator": "^1.0.1",
- "replace-ext": "^1.0.0"
- }
- },
- "vinyl-sourcemaps-apply": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz",
- "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU= sha512-+oDh3KYZBoZC8hfocrbrxbLUeaYtQK7J5WU5Br9VqWqmCll3tFJqKp97GC9GmMsVIL0qnx2DgEDVxdo5EZ5sSw==",
- "dev": true,
- "requires": {
- "source-map": "^0.5.1"
- }
}
}
}
diff --git a/package.json b/package.json
index 6ecb1fa..c4d99e3 100644
--- a/package.json
+++ b/package.json
@@ -7,12 +7,11 @@
"author": "Sam Thorogood ",
"license": "Apache-2.0",
"scripts": {
- "compile": "./compile.sh",
+ "compile": "node ./build.mjs",
"test": "node --test ./test.mjs"
},
"devDependencies": {
"@types/node": "^18.7.13",
- "esbuild": "^0.15.5",
- "google-closure-compiler": "^20220601.0.0"
+ "esbuild": "^0.15.5"
}
}
diff --git a/text.js b/text.js
deleted file mode 100644
index 895090f..0000000
--- a/text.js
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 2017 Sam Thorogood. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- * @fileoverview Polyfill for TextEncoder and TextDecoder.
- *
- * You probably want `text.min.js`, and not this file directly.
- */
-
-(function(scope) {
-'use strict';
-
-// fail early
-if (scope['TextEncoder'] && scope['TextDecoder']) {
- return false;
-}
-
-// Decoding a string is pretty slow, but use alternative options where possible.
-let decodeImpl = decodeFallback;
-if (typeof Buffer === 'function' && Buffer.from) {
- // Buffer.from was added in Node v5.10.0 (2015-11-17).
- decodeImpl = decodeBuffer;
-} else if (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function') {
- // Blob and URL.createObjectURL are available from IE10, Safari 6, Chrome 19
- // (all released in 2012), Firefox 19 (2013), ...
- decodeImpl = decodeSyncXHR;
-}
-
-// used for FastTextDecoder
-const validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];
-
-/**
- * @constructor
- */
-function FastTextEncoder() {
- // This does not accept an encoding, and always uses UTF-8:
- // https://www.w3.org/TR/encoding/#dom-textencoder
-}
-
-Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'});
-
-/**
- * @param {string} string
- * @param {{stream: boolean}=} options
- * @return {!Uint8Array}
- */
-FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) {
- if (options.stream) {
- throw new Error(`Failed to encode: the 'stream' option is unsupported.`);
- }
-
- let pos = 0;
- const len = string.length;
-
- let at = 0; // output position
- let tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size
- let target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset
-
- while (pos < len) {
- let value = string.charCodeAt(pos++);
- if (value >= 0xd800 && value <= 0xdbff) {
- // high surrogate
- if (pos < len) {
- const extra = string.charCodeAt(pos);
- if ((extra & 0xfc00) === 0xdc00) {
- ++pos;
- value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
- }
- }
- if (value >= 0xd800 && value <= 0xdbff) {
- continue; // drop lone surrogate
- }
- }
-
- // expand the buffer if we couldn't write 4 bytes
- if (at + 4 > target.length) {
- tlen += 8; // minimum extra
- tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining
- tlen = (tlen >>> 3) << 3; // 8 byte offset
-
- const update = new Uint8Array(tlen);
- update.set(target);
- target = update;
- }
-
- if ((value & 0xffffff80) === 0) { // 1-byte
- target[at++] = value; // ASCII
- continue;
- } else if ((value & 0xfffff800) === 0) { // 2-byte
- target[at++] = ((value >>> 6) & 0x1f) | 0xc0;
- } else if ((value & 0xffff0000) === 0) { // 3-byte
- target[at++] = ((value >>> 12) & 0x0f) | 0xe0;
- target[at++] = ((value >>> 6) & 0x3f) | 0x80;
- } else if ((value & 0xffe00000) === 0) { // 4-byte
- target[at++] = ((value >>> 18) & 0x07) | 0xf0;
- target[at++] = ((value >>> 12) & 0x3f) | 0x80;
- target[at++] = ((value >>> 6) & 0x3f) | 0x80;
- } else {
- continue; // out of range
- }
-
- target[at++] = (value & 0x3f) | 0x80;
- }
-
- // Use subarray if slice isn't supported (IE11). This will use more memory
- // because the original array still exists.
- return target.slice ? target.slice(0, at) : target.subarray(0, at);
-}
-
-/**
- * @constructor
- * @param {string=} utfLabel
- * @param {{fatal: boolean}=} options
- */
-function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) {
- /** @type {boolean} */
- let ok;
- if (decodeImpl === decodeBuffer) {
- ok = Buffer.isEncoding(utfLabel);
- } else {
- ok = validUtfLabels.indexOf(utfLabel.toLowerCase()) !== -1;
- }
- if (!ok) {
- throw new RangeError(
- `Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`);
- }
- if (options.fatal) {
- throw new Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`);
- }
- this.encoding = utfLabel;
-}
-
-Object.defineProperty(FastTextDecoder.prototype, 'fatal', {value: false});
-
-Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false});
-
-/**
- * @param {!Uint8Array} bytes
- * @param {string} encoding
- * @return {string}
- */
-function decodeBuffer(bytes, encoding) {
- /** @type {Buffer} */
- let b;
- if (bytes instanceof Buffer) {
- b = bytes;
- } else {
- b = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
- }
- return b.toString(encoding);
-}
-
-/**
- * @param {!Uint8Array} bytes
- * @return {string}
- */
-function decodeSyncXHR(bytes) {
- let u;
-
- // This hack will fail in non-Edgium Edge because sync XHRs are disabled (and
- // possibly in other places), so ensure there's a fallback call.
- try {
- const b = new Blob([bytes], {type: 'text/plain;charset=UTF-8'});
- u = URL.createObjectURL(b);
-
- const x = new XMLHttpRequest();
- x.open('GET', u, false);
- x.send();
- return x.responseText;
- } catch (e) {
- return decodeFallback(bytes);
- } finally {
- if (u) {
- URL.revokeObjectURL(u);
- }
- }
-}
-
-/**
- * @param {!Uint8Array} bytes
- * @return {string}
- */
-function decodeFallback(bytes) {
- let inputIndex = 0;
-
- // Create a working buffer for UTF-16 code points, but don't generate one
- // which is too large for small input sizes. UTF-8 to UCS-16 conversion is
- // going to be at most 1:1, if all code points are ASCII. The other extreme
- // is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%
- // fewer entries in the output.
- const pendingSize = Math.min(256 * 256, bytes.length + 1);
- const pending = new Uint16Array(pendingSize);
- const chunks = [];
- let pendingIndex = 0;
-
- for (;;) {
- const more = inputIndex < bytes.length;
-
- // If there's no more data or there'd be no room for two UTF-16 values,
- // create a chunk. This isn't done at the end by simply slicing the data
- // into equal sized chunks as we might hit a surrogate pair.
- if (!more || (pendingIndex >= pendingSize - 1)) {
- // nb. .apply and friends are *really slow*. Low-hanging fruit is to
- // expand this to literally pass pending[0], pending[1], ... etc, but
- // the output code expands pretty fast in this case.
- chunks.push(String.fromCharCode.apply(null, pending.subarray(0, pendingIndex)));
-
- if (!more) {
- return chunks.join('');
- }
-
- // Move the buffer forward and create another chunk.
- bytes = bytes.subarray(inputIndex);
- inputIndex = 0;
- pendingIndex = 0;
- }
-
- // The native TextDecoder will generate "REPLACEMENT CHARACTER" where the
- // input data is invalid. Here, we blindly parse the data even if it's
- // wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.
-
- const byte1 = bytes[inputIndex++];
- if ((byte1 & 0x80) === 0) { // 1-byte or null
- pending[pendingIndex++] = byte1;
- } else if ((byte1 & 0xe0) === 0xc0) { // 2-byte
- const byte2 = bytes[inputIndex++] & 0x3f;
- pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;
- } else if ((byte1 & 0xf0) === 0xe0) { // 3-byte
- const byte2 = bytes[inputIndex++] & 0x3f;
- const byte3 = bytes[inputIndex++] & 0x3f;
- pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;
- } else if ((byte1 & 0xf8) === 0xf0) { // 4-byte
- const byte2 = bytes[inputIndex++] & 0x3f;
- const byte3 = bytes[inputIndex++] & 0x3f;
- const byte4 = bytes[inputIndex++] & 0x3f;
-
- // this can be > 0xffff, so possibly generate surrogates
- let codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
- if (codepoint > 0xffff) {
- // codepoint &= ~0x10000;
- codepoint -= 0x10000;
- pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;
- codepoint = 0xdc00 | codepoint & 0x3ff;
- }
- pending[pendingIndex++] = codepoint;
- } else {
- // invalid initial byte
- }
- }
-}
-
-/**
- * @param {(!ArrayBuffer|!ArrayBufferView)} buffer
- * @param {{stream: boolean}=} options
- * @return {string}
- */
-FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) {
- if (options['stream']) {
- throw new Error(`Failed to decode: the 'stream' option is unsupported.`);
- }
-
- let bytes;
-
- if (buffer instanceof Uint8Array) {
- // Accept Uint8Array instances as-is. This is also a Node buffer.
- bytes = buffer;
- } else if (buffer.buffer instanceof ArrayBuffer) {
- // Look for ArrayBufferView, which isn't a real type, but basically
- // represents all the valid TypedArray types plus DataView. They all have
- // ".buffer" as an instance of ArrayBuffer.
- bytes = new Uint8Array(buffer.buffer);
- } else {
- // The only other valid argument here is that "buffer" is an ArrayBuffer.
- // We also try to convert anything else passed to a Uint8Array, as this
- // catches anything that's array-like. Native code would throw here.
- bytes = new Uint8Array(buffer);
- }
-
- return decodeImpl(/** @type {!Uint8Array} */ (bytes), this.encoding);
-}
-
-scope['TextEncoder'] = FastTextEncoder;
-scope['TextDecoder'] = FastTextDecoder;
-
-}(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));