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:
parent
deaddd212c
commit
25dc25b111
@ -341,21 +341,15 @@ Object.defineProperties(
|
|||||||
value: 'TextEncoder'
|
value: 'TextEncoder'
|
||||||
} });
|
} });
|
||||||
|
|
||||||
const { hasConverter, TextDecoder } =
|
const TextDecoder =
|
||||||
process.binding('config').hasIntl ?
|
process.binding('config').hasIntl ?
|
||||||
makeTextDecoderICU() :
|
makeTextDecoderICU() :
|
||||||
makeTextDecoderJS();
|
makeTextDecoderJS();
|
||||||
|
|
||||||
function hasTextDecoder(encoding = 'utf-8') {
|
|
||||||
validateArgument(encoding, 'string', 'encoding', 'string');
|
|
||||||
return hasConverter(getEncodingFromLabel(encoding));
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTextDecoderICU() {
|
function makeTextDecoderICU() {
|
||||||
const {
|
const {
|
||||||
decode: _decode,
|
decode: _decode,
|
||||||
getConverter,
|
getConverter,
|
||||||
hasConverter
|
|
||||||
} = internalBinding('icu');
|
} = internalBinding('icu');
|
||||||
|
|
||||||
class TextDecoder {
|
class TextDecoder {
|
||||||
@ -409,7 +403,7 @@ function makeTextDecoderICU() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { hasConverter, TextDecoder };
|
return TextDecoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTextDecoderJS() {
|
function makeTextDecoderJS() {
|
||||||
@ -497,7 +491,7 @@ function makeTextDecoderJS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { hasConverter, TextDecoder };
|
return TextDecoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mix in some shared properties.
|
// Mix in some shared properties.
|
||||||
@ -552,7 +546,6 @@ function makeTextDecoderJS() {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getEncodingFromLabel,
|
getEncodingFromLabel,
|
||||||
hasTextDecoder,
|
|
||||||
TextDecoder,
|
TextDecoder,
|
||||||
TextEncoder
|
TextEncoder
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user