btree.js icon indicating copy to clipboard operation
btree.js copied to clipboard

Any way to walkDesc with a limit on number of records?

Open aguynamedben opened this issue 6 years ago • 0 comments

This library is pretty awesome, thanks for spending the time to make it available to others.

I see tree.walk and tree.walkDesc take minKey and maxKey arguments. I was wondering if there was a valid case for them to also take a limit argument. During the walk, the search algorithm could keep track of the number of records returned and stop when limit is hit.

It looks like there's also an undocumented feature that if callback (passed to walkDesc) returns true, the loop is stopped. So I guess my calling function could keep track of the number of times callback is called, then return true when my limit is hit? Does that sound like a good way to use a limit?

Thanks again! This is rad.

aguynamedben avatar Jan 18 '19 22:01 aguynamedben