From 8f3cfc89fa439f0ef7838dca8d379757625afa5e Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 2 Oct 2018 22:30:07 -0400 Subject: [PATCH] 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 Reviewed-By: Daniel Bevenius Reviewed-By: Gus Caplan --- lib/buffer.js | 2 +- lib/internal/bootstrap/node.js | 3 ++- lib/internal/encoding.js | 2 +- lib/internal/readline.js | 2 +- lib/url.js | 2 +- src/node_i18n.cc | 2 +- test/parallel/test-icu-punycode.js | 4 +++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index f274c51739d418..2ceb7ce1c945e4 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -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. diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 65986337c3875c..740314c8c76a0d 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -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. diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 161ae72a19eaef..b2448144b0854a 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -356,7 +356,7 @@ function makeTextDecoderICU() { decode: _decode, getConverter, hasConverter - } = process.binding('icu'); + } = internalBinding('icu'); class TextDecoder { constructor(encoding = 'utf-8', options = {}) { diff --git a/lib/internal/readline.js b/lib/internal/readline.js index 45125db0c223ef..0f7d969d20c218 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -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)) diff --git a/lib/url.js b/lib/url.js index ba2033b4e533aa..db7369fed0bb40 100644 --- a/lib/url.js +++ b/lib/url.js @@ -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'); diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 5966e3ff678e34..fda53cc6d4a5d6 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -882,6 +882,6 @@ void Initialize(Local 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 diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js index 82c15287982631..3744891ee098de 100644 --- a/test/parallel/test-icu-punycode.js +++ b/test/parallel/test-icu-punycode.js @@ -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');