(encoding)
| 84 | const l256 = { __proto__: null, length: 256 }; |
| 85 | |
| 86 | function getEncoding(encoding) { |
| 87 | if (encoding === 'x-user-defined') { |
| 88 | // https://encoding.spec.whatwg.org/#x-user-defined-decoder, 14.5.1. x-user-defined decoder |
| 89 | return TypedArrayFrom(Uint16Array, l256, (_, i) => (i >= 0x80 ? 0xf700 + i : i)); |
| 90 | } |
| 91 | |
| 92 | if (!ObjectPrototypeHasOwnProperty(encodings, encoding)) { |
| 93 | throw new ERR_ENCODING_NOT_SUPPORTED(encoding); |
| 94 | } |
| 95 | |
| 96 | const map = TypedArrayFrom(Uint16Array, l256, (_, i) => i); // Unicode subset |
| 97 | let prev = 127; |
| 98 | map.set(TypedArrayFrom(Uint16Array, it(encodings[encoding]), (x) => (x === r ? x : (prev += x))), 128); |
| 99 | return map; |
| 100 | } |
| 101 | |
| 102 | const supported = new SafeSet(it(ObjectKeys(encodings))).add('iso-8859-8-i').add('x-user-defined'); |
| 103 | const isSinglebyteEncoding = (enc) => supported.has(enc); |
no test coverage detected
searching dependent graphs…