From ffb4087def252db3bb226adcf06baa6c99cc6728 Mon Sep 17 00:00:00 2001 From: Chi-chi Wang Date: Fri, 12 Oct 2018 13:32:55 -0500 Subject: [PATCH] src: remove function hasTextDecoder in encoding.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also... return TextDecoder directly from factories PR-URL: https://github.com/nodejs/node/pull/23625 Reviewed-By: Anna Henningsen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani --- lib/internal/encoding.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 161ae72a19eaef..c0083948e0d72d 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -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 };