tree-crawl icon indicating copy to clipboard operation
tree-crawl copied to clipboard

a way to set `getChildren` to more than one condition?

Open stoplion opened this issue 6 years ago • 1 comments

I have a tree that sometime has a args property and sometimes has a content property. Is a way to set getChildren to more than one condition?

crawl(tree, n => console.log(n.type, n.value || n.op), {
  getChildren: node => node.args ||  node.content
});

stoplion avatar Apr 19 '19 07:04 stoplion

Hey @stoplion,

Sorry for the very late answer 😅. I'm not sure I understand the question. It seems that your code snippet already selectively returns either args or content. Are you trying to achieve something else that I didn't understand?

ngryman avatar Jun 27 '19 07:06 ngryman