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.loadFile = std.loadFile;\n"
|
||||||
" globalThis.printf = console.log;\n"
|
" globalThis.printf = console.log;\n"
|
||||||
" globalThis.evalFile = std.loadScript;\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"
|
" globalThis.getURL = std.urlGet;\n"
|
||||||
"} else {\n"
|
"} else {\n"
|
||||||
" console.error('std is not defined.');\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";
|
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') {
|
if (typeof os !== 'undefined') {
|
||||||
globalThis.sleep = os.sleep
|
globalThis.sleep = os.sleep
|
||||||
async function setTimeout2(func, ms) {globalThis.clearTimeout = false; await sleep(ms); if (!clearTimeout) { func(); } }
|
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.')
|
console.error('os is not defined.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof std !== 'undefined') {
|
if (typeof std !== 'undefined') {
|
||||||
globalThis.urlGet = std.urlGet
|
globalThis.urlGet = std.urlGet
|
||||||
globalThis.loadFile = std.loadFile
|
globalThis.loadFile = std.loadFile
|
||||||
globalThis.printf = console.log
|
globalThis.printf = console.log
|
||||||
globalThis.evalFile = std.loadScript
|
globalThis.evalFile = std.loadScript
|
||||||
// " globalThis.require = std.loadScript"
|
globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);
|
||||||
globalThis.getURL = std.urlGet
|
globalThis.getURL = std.urlGet
|
||||||
} else {
|
} else {
|
||||||
console.error('std is not defined.');
|
console.error('std is not defined.');
|
||||||
}
|
}
|
||||||
|
|
||||||
(function(g) {
|
(function(g) {
|
||||||
|
/* init polyfills */
|
||||||
|
g = globalThis
|
||||||
|
|
||||||
/* add 'bjson', 'os' and 'std' bindings */
|
/* add 'bjson', 'os' and 'std' bindings */
|
||||||
g.bjson = bjson;
|
g.bjson = bjson;
|
||||||
g.os = os;
|
g.os = os;
|
||||||
|
|
Loading…
Reference in a new issue