1
0
silverbullet/plugs/core/lib/syscall.ts
2022-03-14 10:07:38 +01:00

16 lines
484 B
TypeScript

declare global {
function syscall(id: number, name: string, args: any[]): Promise<any>;
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;
}
export async function syscall(name: string, ...args: any[]): Promise<any> {
self.reqId++;
// console.log("Syscall", name, reqId);
return await self.syscall(self.reqId, name, args);
}