Skip to content

Commit 396c553

Browse files
RaisinTentargos
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 62767f3 commit 396c553

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,
@@ -74,7 +75,7 @@ const CONVERTER_FLAGS_IGNORE_BOM = 0x4;
7475

7576
const empty = new Uint8Array(0);
7677

77-
const encodings = new Map([
78+
const encodings = new SafeMap([
7879
['unicode-1-1-utf-8', 'utf-8'],
7980
['utf8', 'utf-8'],
8081
['utf-8', 'utf-8'],
@@ -309,7 +310,7 @@ function trimAsciiWhitespace(label) {
309310
label[e - 1] === '\u0020')) {
310311
e--;
311312
}
312-
return label.slice(s, e);
313+
return StringPrototypeSlice(label, s, e);
313314
}
314315

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

0 commit comments

Comments
 (0)