-
Notifications
You must be signed in to change notification settings - Fork 569
/
_core.ts
29 lines (26 loc) · 839 Bytes
/
_core.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// This module provides an interface to `Deno.core`. For environments
// that don't have access to `Deno.core` some APIs are polyfilled, while
// some are unavailble and throw on call.
// deno-lint-ignore no-explicit-any
export let core: any;
// @ts-ignore Deno.core is not defined in types
if (Deno?.core) {
// @ts-ignore Deno.core is not defined in types
core = Deno.core;
} else {
core = {
setNextTickCallback: undefined,
evalContext(_code: string, _filename: string) {
throw new Error(
"Deno.core.evalContext is not supported in this environment",
);
},
encode(chunk: string): Uint8Array {
return new TextEncoder().encode(chunk);
},
eventLoopHasMoreWork(): boolean {
return false;
},
};
}