Skip to content

Commit

Permalink
src: remove function hasTextDecoder in encoding.js
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
chichiwang authored and jasnell committed Oct 17, 2018
1 parent 74c4bb7 commit 2f6b737
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,15 @@ 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
} = internalBinding('icu');

class TextDecoder {
Expand Down Expand Up @@ -409,7 +403,7 @@ function makeTextDecoderICU() {
}
}

return { hasConverter, TextDecoder };
return TextDecoder;
}

function makeTextDecoderJS() {
Expand Down Expand Up @@ -497,7 +491,7 @@ function makeTextDecoderJS() {
}
}

return { hasConverter, TextDecoder };
return TextDecoder;
}

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

module.exports = {
getEncodingFromLabel,
hasTextDecoder,
TextDecoder,
TextEncoder
};

0 comments on commit 2f6b737

Please sign in to comment.