Skip to content

Commit 01a71dd

Browse files
RaisinTentargos
authored andcommitted
lib: refactor to use more primordials in internal/encoding.js
PR-URL: #36480 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Pooja D P <Pooja.D.P@ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 4983ef2 commit 01a71dd

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎lib/internal/encoding.js‎

Lines changed: 5 additions & 4 deletions
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
constempty=newUint8Array(0);
7677

77-
constencodings=newMap([
78+
constencodings=newSafeMap([
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-
returnlabel.slice(s,e);
313+
returnStringPrototypeSlice(label,s,e);
313314
}
314315

315316
functiongetEncodingFromLabel(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)