Add files via upload

This commit is contained in:
The Ghost of FOSS' Future 2025-01-06 15:50:00 -06:00 committed by GitHub
parent 30c9be7281
commit f9809db69a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

2
qjs.c
View file

@ -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
View file

@ -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;