summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-12 11:55:13 -0700
committerAnna Henningsen <anna@addaleax.net>2018-09-17 17:09:25 +0200
commit932be0164fb3ed869ae3ddfff391721d2fd8e1af (patch)
tree4eb32dfe566fa20fe9bc6a7f265122c57dab61f6 /lib
parentefe0bbcd2fde5f60546fa2dc60295956ba440a3c (diff)
downloadandroid-node-v8-932be0164fb3ed869ae3ddfff391721d2fd8e1af.tar.gz
android-node-v8-932be0164fb3ed869ae3ddfff391721d2fd8e1af.tar.bz2
android-node-v8-932be0164fb3ed869ae3ddfff391721d2fd8e1af.zip
util: make TextEncoder/TextDecoder global
Fixes: https://github.com/nodejs/node/issues/20365 PR-URL: https://github.com/nodejs/node/pull/22281 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/bootstrap/node.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 7af3a8ad4a..fc8d8a2809 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -127,6 +127,7 @@
setupGlobalTimeouts();
setupGlobalConsole();
setupGlobalURL();
+ setupGlobalEncoding();
}
if (process.binding('config').experimentalWorker) {
@@ -476,6 +477,24 @@
});
}
+ function setupGlobalEncoding() {
+ const { TextEncoder, TextDecoder } = NativeModule.require('util');
+ Object.defineProperties(global, {
+ TextEncoder: {
+ value: TextEncoder,
+ writable: true,
+ configurable: true,
+ enumerable: false
+ },
+ TextDecoder: {
+ value: TextDecoder,
+ writable: true,
+ configurable: true,
+ enumerable: false
+ }
+ });
+ }
+
function setupDOMException() {
// Registers the constructor with C++.
NativeModule.require('internal/domexception');