Skip to content

Commit

Permalink
lib: refactor to use more primordials in internal/encoding.js
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RaisinTen authored and targos committed Jun 11, 2021
1 parent 4983ef2 commit 01a71dd
Showing 1 changed file with 5 additions and 4 deletions.
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 @@ -74,7 +75,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 @@ -309,7 +310,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 @@ -504,7 +505,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

0 comments on commit 01a71dd

Please sign in to comment.