2022-04-05 23:02:17 +08:00
|
|
|
import fetch, { RequestInfo, RequestInit } from "node-fetch";
|
|
|
|
import { SysCallMapping } from "../system";
|
2022-03-25 19:03:06 +08:00
|
|
|
|
|
|
|
export function fetchSyscalls(): SysCallMapping {
|
|
|
|
return {
|
2022-04-04 00:42:12 +08:00
|
|
|
"fetch.json": async (ctx, url: RequestInfo, init: RequestInit) => {
|
2022-03-25 19:03:06 +08:00
|
|
|
let resp = await fetch(url, init);
|
|
|
|
return resp.json();
|
|
|
|
},
|
2022-04-04 17:51:41 +08:00
|
|
|
"fetch.text": async (ctx, url: RequestInfo, init: RequestInit) => {
|
2022-03-25 19:03:06 +08:00
|
|
|
let resp = await fetch(url, init);
|
|
|
|
return resp.text();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|