refactor: transparently resolve traversal invocation arg promises
This commit is contained in:
parent
80b57e0e7f
commit
e690967cb8
|
@ -85,7 +85,23 @@ class Context extends Map {
|
|||
return node[step.key];
|
||||
case 'invoke':
|
||||
const args = step.args.map((arg) => arg.get(this));
|
||||
// Any arg promises will be resolved; the arg values will be passed
|
||||
// transparently to the invocation.
|
||||
let hasPromise = false;
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] instanceof Promise) {
|
||||
hasPromise = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasPromise) {
|
||||
return Promise.all(args).then((args) => {
|
||||
return fastApply(previousNode, node, args);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return fastApply(previousNode, node, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user