robtweed / ewd-document-store

Persistent JavaScript Objects and Document Database using Global Storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

forEachChild / forEachLeafNode question

killmenot opened this issue · comments

Hey @robtweed

forEachLeafNode and forEachChild return first parameter in callback differently
forEachLeafNode: node.data
forEachChild: node.result

I think you know about it, just want to make sure

Yes it's correct.

forEachLeafNode iterates directly through leaf nodes, so the two things you want to know on each iteration are the value of that leaf node (node.data) and a pointer to the leaf node's DocumentNode.

forEachChild iterates down the subscripts at a particular level of subscripting, so you want to know the subscript value (node.result). If you want the data, you can get it from the DocumentNode that you're given at each iteration.

Good question though :-)