1
0
silverbullet/plugos/syscalls/transport.ts

21 lines
435 B
TypeScript
Raw Normal View History

import { SyscallContext, SysCallMapping } from "../system.ts";
2022-03-25 11:03:06 +00:00
2022-04-05 15:02:17 +00:00
export function proxySyscalls(
2022-03-25 11:03:06 +00:00
names: string[],
transportCall: (
ctx: SyscallContext,
name: string,
...args: any[]
) => Promise<any>,
2022-03-25 11:03:06 +00:00
): SysCallMapping {
const syscalls: SysCallMapping = {};
2022-03-25 11:03:06 +00:00
for (const name of names) {
2022-03-25 11:03:06 +00:00
syscalls[name] = (ctx, ...args: any[]) => {
return transportCall(ctx, name, ...args);
2022-03-25 11:03:06 +00:00
};
}
return syscalls;
}