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:
parent
9b4da88a96
commit
7630326b4c
3 changed files with 34 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue