0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
denoland-deno/cli/js/dispatch.ts

24 lines
666 B
TypeScript
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as minimal from "./ops/dispatch_minimal.ts";
import * as json from "./ops/dispatch_json.ts";
import { AsyncHandler } from "./plugins.ts";
const PLUGIN_ASYNC_HANDLER_MAP: Map<number, AsyncHandler> = new Map();
export function setPluginAsyncHandler(
opId: number,
handler: AsyncHandler
): void {
PLUGIN_ASYNC_HANDLER_MAP.set(opId, handler);
}
2019-05-03 00:06:43 -04:00
export function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
switch (opName) {
2020-02-25 09:14:27 -05:00
case "op_write":
case "op_read":
return minimal.asyncMsgFromRust;
default:
return json.asyncMsgFromRust;
}
}