summaryrefslogtreecommitdiff
path: root/cli/js/runtime.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-06-21 16:34:43 +0200
committerGitHub <noreply@github.com>2020-06-21 16:34:43 +0200
commit79adc7b000a807caff01a3639b18cb91aef9bd9c (patch)
tree8592baf9a2d88aea7a55f55903739b63bd23fded /cli/js/runtime.ts
parent86448fd9aaa9d70078f7928c9ea1d5af2679ea08 (diff)
core: add Deno.core.dispatchByName (#6395)
This commit adds alternate dispatch method to core JS API. "Deno.core.dispatchByName()" works like "Deno.core.dispatch()", but takes op name instead of op id as a first argument.
Diffstat (limited to 'cli/js/runtime.ts')
-rw-r--r--cli/js/runtime.ts6
1 files changed, 2 insertions, 4 deletions
diff --git a/cli/js/runtime.ts b/cli/js/runtime.ts
index e16cee228..39d158f71 100644
--- a/cli/js/runtime.ts
+++ b/cli/js/runtime.ts
@@ -9,8 +9,6 @@ import { setPrepareStackTrace } from "./error_stack.ts";
import { Start, opStart } from "./ops/runtime.ts";
import { handleTimerMacrotask } from "./web/timers.ts";
-export let OPS_CACHE: { [name: string]: number };
-
function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
switch (opName) {
case "op_write":
@@ -24,8 +22,8 @@ function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
// TODO(bartlomieju): temporary solution, must be fixed when moving
// dispatches to separate crates
export function initOps(): void {
- OPS_CACHE = core.ops();
- for (const [name, opId] of Object.entries(OPS_CACHE)) {
+ const opsMap = core.ops();
+ for (const [name, opId] of Object.entries(opsMap)) {
core.setAsyncHandler(opId, getAsyncHandler(name));
}
core.setMacrotaskCallback(handleTimerMacrotask);