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 <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
chichiwang authored and MylesBorins committed Dec 26, 2018
1 parent b3e1205 commit ffb4087
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
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 ffb4087

Please sign in to comment.