mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Add files via upload
This commit is contained in:
parent
30c9be7281
commit
f9809db69a
2 changed files with 10 additions and 4 deletions
2
qjs.c
2
qjs.c
|
@ -174,7 +174,7 @@ static int eval_file(JSContext *ctx, const char *filename, int module)
|
|||
" globalThis.loadFile = std.loadFile;\n"
|
||||
" globalThis.printf = console.log;\n"
|
||||
" globalThis.evalFile = std.loadScript;\n"
|
||||
//" globalThis.require = std.loadScript;\n"
|
||||
" globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);\n"
|
||||
" globalThis.getURL = std.urlGet;\n"
|
||||
"} else {\n"
|
||||
" console.error('std is not defined.');\n"
|
||||
|
|
12
repl.js
12
repl.js
|
@ -27,6 +27,11 @@ import * as os from "qjs:os";
|
|||
import * as bjson from "qjs:bjson";
|
||||
|
||||
|
||||
globalThis.global = globalThis
|
||||
globalThis.safeGlobal = {}
|
||||
global.console.error = console.log
|
||||
global.console.warn = console.log
|
||||
|
||||
if (typeof os !== 'undefined') {
|
||||
globalThis.sleep = os.sleep
|
||||
async function setTimeout2(func, ms) {globalThis.clearTimeout = false; await sleep(ms); if (!clearTimeout) { func(); } }
|
||||
|
@ -35,20 +40,21 @@ if (typeof os !== 'undefined') {
|
|||
console.error('os is not defined.')
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (typeof std !== 'undefined') {
|
||||
globalThis.urlGet = std.urlGet
|
||||
globalThis.loadFile = std.loadFile
|
||||
globalThis.printf = console.log
|
||||
globalThis.evalFile = std.loadScript
|
||||
// " globalThis.require = std.loadScript"
|
||||
globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);
|
||||
globalThis.getURL = std.urlGet
|
||||
} else {
|
||||
console.error('std is not defined.');
|
||||
}
|
||||
|
||||
(function(g) {
|
||||
/* init polyfills */
|
||||
g = globalThis
|
||||
|
||||
/* add 'bjson', 'os' and 'std' bindings */
|
||||
g.bjson = bjson;
|
||||
g.os = os;
|
||||
|
|
Loading…
Reference in a new issue