Skip to content

Commit ffb4087

Browse files
chichiwangMylesBorins
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 b3e1205 commit ffb4087

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

‎lib/internal/encoding.js‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,22 +341,16 @@ Object.defineProperties(
341341
value: 'TextEncoder'
342342
}});
343343

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

349-
functionhasTextDecoder(encoding='utf-8'){
350-
validateArgument(encoding,'string','encoding','string');
351-
returnhasConverter(getEncodingFromLabel(encoding));
352-
}
353-
354349
functionmakeTextDecoderICU(){
355350
const{
356351
decode: _decode,
357352
getConverter,
358-
hasConverter
359-
}=process.binding('icu');
353+
}=internalBinding('icu');
360354

361355
classTextDecoder{
362356
constructor(encoding='utf-8',options={}){
@@ -409,7 +403,7 @@ function makeTextDecoderICU() {
409403
}
410404
}
411405

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

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

500-
return{ hasConverter,TextDecoder};
494+
returnTextDecoder;
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)