-
-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
🙋 no/questionThis does not need any changesThis does not need any changes
Description
In my opinion, this should be working:
await visit( tree, 'code', visitor )
function visitor( node, index, parent ) {
return new Promise( resolve => {
const removeNode = () => {
parent.children.splice( index, 1 );
resolve()
}
setTimeout( removeNode, 10 );
})
}
Another (more abstract) example:
await visit( tree, 'code', visitor )
async function visitor( node, index, parent ) {
node.value = await someAsyncStuff();
}
Background
Visitor might do:
- read a node
- perform an action based on the node value/props (reading/writing files, do a HTTP request, ...)
- modify the tree based on the result of async operation
However, currently, only sync operations are allowed. That's why it cannot be used for async transformers, which should be supported by unified.
kendallstrautman, ooker777 and aryaemami59
Metadata
Metadata
Assignees
Labels
🙋 no/questionThis does not need any changesThis does not need any changes