'use strict';
(({ textEncoderEncode, textEncoderEncodeInto, textDecoderDecode }) => {
class TextEncoder {
constructor() {
}
get encoding() {
return 'utf-8';
}
encode(input = '') {
return textEncoderEncode(String(input));
}
encodeInto(source, destination) {
if (!(destination instanceof Uint8Array)) {
throw new TypeError('Destination must be a Uint8Array');
}
return textEncoderEncodeInto(String(source), destination);
}
}
class TextDecoder {
#encoding;
#fatal;
#ignoreBOM;
constructor(label = 'utf-8', options = {}) {
const encoding = String(label).toLowerCase().trim();
if (encoding !== 'utf-8' && encoding !== 'utf8' && encoding !== 'unicode-1-1-utf-8') {
throw new RangeError(`The encoding label provided ('${label}') is invalid.`);
}
this.#encoding = 'utf-8';
this.#fatal = Boolean(options.fatal);
this.#ignoreBOM = Boolean(options.ignoreBOM);
}
get encoding() {
return this.#encoding;
}
get fatal() {
return this.#fatal;
}
get ignoreBOM() {
return this.#ignoreBOM;
}
decode(input, options = {}) {
if (input === undefined || input === null) {
return '';
}
return textDecoderDecode(input);
}
}
Object.defineProperty(globalThis, 'TextEncoder', {
value: TextEncoder,
writable: true,
enumerable: false,
configurable: true,
});
Object.defineProperty(globalThis, 'TextDecoder', {
value: TextDecoder,
writable: true,
enumerable: false,
configurable: true,
});
});