aboutsummaryrefslogtreecommitdiff
path: root/utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-07-28 15:32:10 +1000
committerYuchen Pei <hi@ypei.me>2022-07-28 15:32:10 +1000
commit5b10a10743b8459f64fe83e0ff420f69da79c9a4 (patch)
treec61904d688247790181d4955a4074b8c94302c03 /utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js
parentb98cb70b1bcd5b211aaa5d2675f96416911c0647 (diff)
Moving scripts and utilities into a new utilities dir
Diffstat (limited to 'utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js')
-rw-r--r--utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js b/utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js
new file mode 100644
index 0000000..1050872
--- /dev/null
+++ b/utilities/hash_script/node_modules/iconv-lite/lib/bom-handling.js
@@ -0,0 +1,52 @@
+"use strict";
+
+var BOMChar = '\uFEFF';
+
+exports.PrependBOM = PrependBOMWrapper
+function PrependBOMWrapper(encoder, options) {
+ this.encoder = encoder;
+ this.addBOM = true;
+}
+
+PrependBOMWrapper.prototype.write = function(str) {
+ if (this.addBOM) {
+ str = BOMChar + str;
+ this.addBOM = false;
+ }
+
+ return this.encoder.write(str);
+}
+
+PrependBOMWrapper.prototype.end = function() {
+ return this.encoder.end();
+}
+
+
+//------------------------------------------------------------------------------
+
+exports.StripBOM = StripBOMWrapper;
+function StripBOMWrapper(decoder, options) {
+ this.decoder = decoder;
+ this.pass = false;
+ this.options = options || {};
+}
+
+StripBOMWrapper.prototype.write = function(buf) {
+ var res = this.decoder.write(buf);
+ if (this.pass || !res)
+ return res;
+
+ if (res[0] === BOMChar) {
+ res = res.slice(1);
+ if (typeof this.options.stripBOM === 'function')
+ this.options.stripBOM();
+ }
+
+ this.pass = true;
+ return res;
+}
+
+StripBOMWrapper.prototype.end = function() {
+ return this.decoder.end();
+}
+