fix: script stuff
This commit is contained in:
parent
deb88b07ba
commit
8ffe1451a1
|
@ -32,8 +32,14 @@ export default class Script {
|
||||||
static contextDefaults() {
|
static contextDefaults() {
|
||||||
return {
|
return {
|
||||||
console,
|
console,
|
||||||
|
Array,
|
||||||
Math,
|
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;
|
this.sandbox.context.elapsed = elapsed;
|
||||||
const {done, value} = this.sandbox.step();
|
const {done, value} = this.sandbox.step();
|
||||||
if (value) {
|
if (value) {
|
||||||
const {value: result} = value;
|
const {async, value: result} = value;
|
||||||
if (result instanceof Promise) {
|
if (async) {
|
||||||
this.promise = result;
|
this.promise = result;
|
||||||
result
|
result
|
||||||
.catch(reject)
|
.catch(reject)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user