Skip to content

Commit 6e338da

Browse files
RaisinTendanielleadams
authored andcommitted
lib: refactor to use more primordials in internal/encoding.js
PR-URL: #36480 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Pooja D P <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 1ed517c commit 6e338da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/encoding.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
// https://encoding.spec.whatwg.org
55

66
const {
7-
Map,
87
ObjectCreate,
98
ObjectDefineProperties,
109
ObjectGetOwnPropertyDescriptors,
10+
SafeMap,
11+
StringPrototypeSlice,
1112
Symbol,
1213
SymbolToStringTag,
1314
Uint32Array,
@@ -73,7 +74,7 @@ const CONVERTER_FLAGS_IGNORE_BOM = 0x4;
7374

7475
const empty = new Uint8Array(0);
7576

76-
const encodings = new Map([
77+
const encodings = new SafeMap([
7778
['unicode-1-1-utf-8', 'utf-8'],
7879
['utf8', 'utf-8'],
7980
['utf-8', 'utf-8'],
@@ -308,7 +309,7 @@ function trimAsciiWhitespace(label) {
308309
label[e - 1] === '\u0020')) {
309310
e--;
310311
}
311-
return label.slice(s, e);
312+
return StringPrototypeSlice(label, s, e);
312313
}
313314

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

0 commit comments

Comments
 (0)