blob: db10db8ca1e1b14d53b2d896017bdff2818e7e43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as minimal from "./dispatch_minimal.ts";
import * as json from "./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);
}
export function getAsyncHandler(opName: string): (msg: Uint8Array) => void {
switch (opName) {
case "op_write":
case "op_read":
return minimal.asyncMsgFromRust;
default:
return json.asyncMsgFromRust;
}
}
|