summaryrefslogtreecommitdiff
path: root/std/node
diff options
context:
space:
mode:
Diffstat (limited to 'std/node')
-rw-r--r--std/node/_utils.ts6
-rw-r--r--std/node/util.ts10
-rw-r--r--std/node/util_test.ts18
3 files changed, 34 insertions, 0 deletions
diff --git a/std/node/_utils.ts b/std/node/_utils.ts
index ec89d11a8..352179f4a 100644
--- a/std/node/_utils.ts
+++ b/std/node/_utils.ts
@@ -3,6 +3,12 @@ export function notImplemented(msg?: string): never {
throw new Error(message);
}
+export type _TextDecoder = typeof TextDecoder.prototype;
+export const _TextDecoder = TextDecoder;
+
+export type _TextEncoder = typeof TextEncoder.prototype;
+export const _TextEncoder = TextEncoder;
+
// API helpers
export type MaybeNull<T> = T | null;
diff --git a/std/node/util.ts b/std/node/util.ts
index a61dc30b2..8c3fdabe8 100644
--- a/std/node/util.ts
+++ b/std/node/util.ts
@@ -70,3 +70,13 @@ export function validateIntegerRange(
);
}
}
+
+import { _TextDecoder, _TextEncoder } from "./_utils.ts";
+
+/** The global TextDecoder */
+export type TextDecoder = import("./_utils.ts")._TextDecoder;
+export const TextDecoder = _TextDecoder;
+
+/** The global TextEncoder */
+export type TextEncoder = import("./_utils.ts")._TextEncoder;
+export const TextEncoder = _TextEncoder;
diff --git a/std/node/util_test.ts b/std/node/util_test.ts
index b4e6ea41f..7036368b6 100644
--- a/std/node/util_test.ts
+++ b/std/node/util_test.ts
@@ -148,3 +148,21 @@ test({
assert(!util.isPrimitive(objectType));
},
});
+
+test({
+ name: "[util] TextDecoder",
+ fn() {
+ assert(util.TextDecoder === TextDecoder);
+ const td: util.TextDecoder = new util.TextDecoder();
+ assert(td instanceof TextDecoder);
+ },
+});
+
+test({
+ name: "[util] TextEncoder",
+ fn() {
+ assert(util.TextEncoder === TextEncoder);
+ const te: util.TextEncoder = new util.TextEncoder();
+ assert(te instanceof TextEncoder);
+ },
+});