1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-26 16:09:27 -05:00

feat(std/node) Export TextDecoder and TextEncoder from util (#5663)

This commit is contained in:
Garrone Joseph 2020-05-20 16:35:51 +02:00 committed by GitHub
parent 9b4da88a96
commit 7630326b4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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);
},
});