Skip to content

Commit

Permalink
fix: compact children before counting them
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 21, 2018
1 parent c0c48bd commit 56a2ece
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Bucket {
}

leafCount () {
return this._children.reduce((acc, child) => {
return this._children.compactArray().reduce((acc, child) => {
if (child instanceof Bucket) {
return acc + child.leafCount()
}
Expand Down
2 changes: 1 addition & 1 deletion test/hamt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('HAMT', () => {
// insert enough keys to cause multiple buckets to be created
await insertKeys(400, bucket)

expect(bucket.leafCount()).to.eql(22622)
expect(bucket.leafCount()).to.eql(400)
})

it('should count children', async () => {
Expand Down

0 comments on commit 56a2ece

Please sign in to comment.