icu: make process.binding('icu') internal

PR-URL: https://github.com/nodejs/node/pull/23234
Refs: https://github.com/nodejs/node/issues/22160
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
pull/23234/head
cjihrig 2018-10-02 22:30:07 -04:00
parent 9930529805
commit 2498c7b18b
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
7 changed files with 10 additions and 7 deletions

View File

@ -1078,7 +1078,7 @@ if (process.binding('config').hasIntl) {
const {
icuErrName,
transcode: _transcode
} = process.binding('icu');
} = internalBinding('icu');
// Transcodes the Buffer from one encoding to another, returning a new
// Buffer instance.

View File

@ -394,6 +394,7 @@
new SafeSet([
'cares_wrap',
'fs_event_wrap',
'icu',
'udp_wrap',
'uv',
'pipe_wrap',
@ -654,7 +655,7 @@
function setupProcessICUVersions() {
const icu = process.binding('config').hasIntl ?
process.binding('icu') : undefined;
internalBinding('icu') : undefined;
if (!icu) return; // no Intl/ICU: nothing to add here.
// With no argument, getVersion() returns a comma separated list
// of possible types.

View File

@ -356,7 +356,7 @@ function makeTextDecoderICU() {
decode: _decode,
getConverter,
hasConverter
} = process.binding('icu');
} = internalBinding('icu');
class TextDecoder {
constructor(encoding = 'utf-8', options = {}) {

View File

@ -31,7 +31,7 @@ CSI.kClearLine = CSI`2K`;
CSI.kClearScreenDown = CSI`0J`;
if (process.binding('config').hasIntl) {
const icu = process.binding('icu');
const icu = internalBinding('icu');
getStringWidth = function getStringWidth(str, options) {
options = options || {};
if (!Number.isInteger(str))

View File

@ -22,7 +22,7 @@
'use strict';
const { toASCII } = process.binding('config').hasIntl ?
process.binding('icu') : require('punycode');
internalBinding('icu') : require('punycode');
const { hexTable } = require('internal/querystring');

View File

@ -882,6 +882,6 @@ void Initialize(Local<Object> target,
} // namespace i18n
} // namespace node
NODE_BUILTIN_MODULE_CONTEXT_AWARE(icu, node::i18n::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(icu, node::i18n::Initialize)
#endif // NODE_HAVE_I18N_SUPPORT

View File

@ -1,10 +1,12 @@
'use strict';
// Flags: --expose-internals
const common = require('../common');
if (!common.hasIntl)
common.skip('missing Intl');
const icu = process.binding('icu');
const { internalBinding } = require('internal/test/binding');
const icu = internalBinding('icu');
const assert = require('assert');
const tests = require('../fixtures/url-idna.js');