1
0
silverbullet/plugs/core/lib/syscall.ts

16 lines
484 B
TypeScript
Raw Normal View History

2022-03-07 09:21:02 +00:00
declare global {
function syscall(id: number, name: string, args: any[]): Promise<any>;
2022-03-14 09:07:38 +00: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 09:21:02 +00:00
}
export async function syscall(name: string, ...args: any[]): Promise<any> {
2022-03-14 09:07:38 +00:00
self.reqId++;
2022-02-27 09:17:43 +00:00
// console.log("Syscall", name, reqId);
2022-03-14 09:07:38 +00:00
return await self.syscall(self.reqId, name, args);
2022-02-24 16:24:49 +00:00
}