Skip to content

Commit 2f6b737

Browse files
chichiwangjasnell
authored andcommitted
src: remove function hasTextDecoder in encoding.js
also... return TextDecoder directly from factories PR-URL: #23625 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 74c4bb7 commit 2f6b737

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/internal/encoding.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -341,21 +341,15 @@ Object.defineProperties(
341341
value: 'TextEncoder'
342342
} });
343343

344-
const { hasConverter, TextDecoder } =
344+
const TextDecoder =
345345
process.binding('config').hasIntl ?
346346
makeTextDecoderICU() :
347347
makeTextDecoderJS();
348348

349-
function hasTextDecoder(encoding = 'utf-8') {
350-
validateArgument(encoding, 'string', 'encoding', 'string');
351-
return hasConverter(getEncodingFromLabel(encoding));
352-
}
353-
354349
function makeTextDecoderICU() {
355350
const {
356351
decode: _decode,
357352
getConverter,
358-
hasConverter
359353
} = internalBinding('icu');
360354

361355
class TextDecoder {
@@ -409,7 +403,7 @@ function makeTextDecoderICU() {
409403
}
410404
}
411405

412-
return { hasConverter, TextDecoder };
406+
return TextDecoder;
413407
}
414408

415409
function makeTextDecoderJS() {
@@ -497,7 +491,7 @@ function makeTextDecoderJS() {
497491
}
498492
}
499493

500-
return { hasConverter, TextDecoder };
494+
return TextDecoder;
501495
}
502496

503497
// Mix in some shared properties.
@@ -552,7 +546,6 @@ function makeTextDecoderJS() {
552546

553547
module.exports = {
554548
getEncodingFromLabel,
555-
hasTextDecoder,
556549
TextDecoder,
557550
TextEncoder
558551
};

0 commit comments

Comments
 (0)