Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: refactor to use more primordials in internal/encoding.js #36480

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/internal/encoding.js
Expand Up @@ -4,10 +4,11 @@
// https://encoding.spec.whatwg.org

const {
Map,
ObjectCreate,
ObjectDefineProperties,
ObjectGetOwnPropertyDescriptors,
SafeMap,
StringPrototypeSlice,
Symbol,
SymbolToStringTag,
Uint32Array,
Expand Down Expand Up @@ -73,7 +74,7 @@ const CONVERTER_FLAGS_IGNORE_BOM = 0x4;

const empty = new Uint8Array(0);

const encodings = new Map([
const encodings = new SafeMap([
['unicode-1-1-utf-8', 'utf-8'],
['utf8', 'utf-8'],
['utf-8', 'utf-8'],
Expand Down Expand Up @@ -308,7 +309,7 @@ function trimAsciiWhitespace(label) {
label[e - 1] === '\u0020')) {
e--;
}
return label.slice(s, e);
return StringPrototypeSlice(label, s, e);
}

function getEncodingFromLabel(label) {
Expand Down Expand Up @@ -503,7 +504,7 @@ function makeTextDecoderJS() {
// If the very first result in the stream is a BOM, and we are not
// explicitly told to ignore it, then we discard it.
if (result[0] === '\ufeff') {
result = result.slice(1);
result = StringPrototypeSlice(result, 1);
}
this[kBOMSeen] = true;
}
Expand Down