fix: script stuff

This commit is contained in:
cha0s 2024-06-28 13:10:05 -05:00
parent deb88b07ba
commit 8ffe1451a1

View File

@ -32,8 +32,14 @@ export default class Script {
static contextDefaults() {
return {
console,
Array,
Math,
wait: (ms) => new Promise((resolve) => { setTimeout(resolve, ms); }),
Promise,
wait: (seconds) => (
new Promise((resolve) => {
setTimeout(resolve, seconds * 1000);
})
),
};
}
@ -109,8 +115,8 @@ export default class Script {
this.sandbox.context.elapsed = elapsed;
const {done, value} = this.sandbox.step();
if (value) {
const {value: result} = value;
if (result instanceof Promise) {
const {async, value: result} = value;
if (async) {
this.promise = result;
result
.catch(reject)