refactor: pass through promise

This commit is contained in:
cha0s 2024-08-01 13:00:21 -05:00
parent 93cb69e99a
commit 8583772652

View File

@ -704,7 +704,10 @@ export default class Sandbox {
switch (result.yield) {
case YIELD_PROMISE: {
stepResult.async = true;
stepResult.value = Promise.resolve(result.value)
const promise = result.value instanceof Promise
? result.value
: Promise.resolve(result.value);
promise
.then((value) => {
const top = this.$$execution.stack[this.$$execution.stack.length - 1];
this.$$execution.deferred.set(top, {
@ -712,6 +715,7 @@ export default class Sandbox {
yield: YIELD_NONE,
});
});
stepResult.value = promise;
break;
}
case YIELD_LOOP_UPDATE: {