Compare commits
2 commits
8f39c02ea6
...
807be22562
Author | SHA1 | Date | |
---|---|---|---|
807be22562 | |||
d838e9cc47 |
1 changed files with 7 additions and 13 deletions
20
qjs.c
20
qjs.c
|
@ -497,27 +497,21 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
//POLYFILLS BEGIN
|
||||
|
||||
////Require and Global
|
||||
const char *reqPF = "async function require(x) {\n"
|
||||
const char *pf = "async function require(x) {\n"
|
||||
" const y = await import(x);" // use dynamic import.
|
||||
" return y;\n"
|
||||
"}\n"
|
||||
"globalThis.require = require;\n"
|
||||
"globalThis.global = globalThis;\n";
|
||||
eval_buf(ctx, reqPF, strlen(reqPF), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
|
||||
|
||||
const char *timeoutPF = "globalThis.setTimeout = os.setTimeout\n"
|
||||
"globalThis.sleep = os.sleep";
|
||||
eval_buf(ctx, timeoutPF, strlen(timeoutPF), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
|
||||
const char *stdGlobals = "globalThis.urlGet = std.urlGet\n"
|
||||
"globalThis.global = globalThis;\n"
|
||||
"globalThis.setTimeout = os.setTimeout\n"
|
||||
"globalThis.clearTimeout = os.clearTimeout\n"
|
||||
"globalThis.sleep = os.sleep\n"
|
||||
"globalThis.urlGet = std.urlGet\n"
|
||||
"globalThis.loadFile = std.loadFile\n"
|
||||
"globalThis.printf = std.printf\n"
|
||||
"globalThis.evalFile = std.loadScript\n"
|
||||
"globalThis.getURL = std.urlGet";
|
||||
eval_buf(ctx, stdGlobals, strlen(stdGlobals), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
eval_buf(ctx, pf, strlen(pf), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
|
||||
|
||||
for(i = 0; i < include_count; i++) {
|
||||
|
|
Loading…
Reference in a new issue