silverbullet/plugs/core/lib/syscall.ts

16 lines
484 B
TypeScript
Raw Normal View History

2022-03-07 17:21:02 +08:00
declare global {
function syscall(id: number, name: string, args: any[]): Promise<any>;
2022-03-14 17:07:38 +08:00
var reqId: number;
}
// This needs to be global, because this will be shared with all other functions in the same environment (worker-like)
if (typeof self.reqId === "undefined") {
self.reqId = 0;
2022-03-07 17:21:02 +08:00
}
export async function syscall(name: string, ...args: any[]): Promise<any> {
2022-03-14 17:07:38 +08:00
self.reqId++;
2022-02-27 17:17:43 +08:00
// console.log("Syscall", name, reqId);
2022-03-14 17:07:38 +08:00
return await self.syscall(self.reqId, name, args);
2022-02-25 00:24:49 +08:00
}