mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
src: remove function hasTextDecoder in encoding.js
also... return TextDecoder directly from factories PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
b3e1205008
commit
ffb4087def
1 file changed
+4
-11
@@ -341,22 +341,16 @@ Object.defineProperties(
|
||||
value: 'TextEncoder'
|
||||
} });
|
||||
|
||||
const { hasConverter, TextDecoder } =
|
||||
const TextDecoder =
|
||||
process.binding('config').hasIntl ?
|
||||
makeTextDecoderICU() :
|
||||
makeTextDecoderJS();
|
||||
|
||||
function hasTextDecoder(encoding = 'utf-8') {
|
||||
validateArgument(encoding, 'string', 'encoding', 'string');
|
||||
return hasConverter(getEncodingFromLabel(encoding));
|
||||
}
|
||||
|
||||
function makeTextDecoderICU() {
|
||||
const {
|
||||
decode: _decode,
|
||||
getConverter,
|
||||
hasConverter
|
||||
} = process.binding('icu');
|
||||
} = internalBinding('icu');
|
||||
|
||||
class TextDecoder {
|
||||
constructor(encoding = 'utf-8', options = {}) {
|
||||
@@ -409,7 +403,7 @@ function makeTextDecoderICU() {
|
||||
}
|
||||
}
|
||||
|
||||
return { hasConverter, TextDecoder };
|
||||
return TextDecoder;
|
||||
}
|
||||
|
||||
function makeTextDecoderJS() {
|
||||
@@ -497,7 +491,7 @@ function makeTextDecoderJS() {
|
||||
}
|
||||
}
|
||||
|
||||
return { hasConverter, TextDecoder };
|
||||
return TextDecoder;
|
||||
}
|
||||
|
||||
// Mix in some shared properties.
|
||||
@@ -552,7 +546,6 @@ function makeTextDecoderJS() {
|
||||
|
||||
module.exports = {
|
||||
getEncodingFromLabel,
|
||||
hasTextDecoder,
|
||||
TextDecoder,
|
||||
TextEncoder
|
||||
};
|
||||
Reference in new issue
Block a user