unjs / rou3

🌳 Lightweight and fast rou(ter) for JavaScript
MIT License
442 stars 16 forks source link

fix: use Map size to calculate the number of children #73

Closed AndrewWalsh closed 10 months ago

AndrewWalsh commented 10 months ago

fix: use Map size property to calculate the number of children. The current approach does not count them correctly

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size

πŸ”— Linked issue

❓ Type of change

πŸ“š Description

πŸ“ Checklist

pi0 commented 10 months ago

Thanks for the PR! Is there a chance you can add a fixture to the tests that were previously failing? πŸ™πŸΌ

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (fe00560) 95.63% compared to head (4a744e0) 95.63%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #73 +/- ## ======================================= Coverage 95.63% 95.63% ======================================= Files 4 4 Lines 435 435 Branches 83 84 +1 ======================================= Hits 416 416 Misses 19 19 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

AndrewWalsh commented 10 months ago

Thanks for taking a look @pi0. I've written a test to cover this. Changing node.children.size === 0 to Object.keys(node.children).length === 0 will make this fail.

pi0 commented 10 months ago

@AndrewWalsh Since main branch is already prepared for 2.x release, this patch will be included in 2.x once released but please let me know if it is something blocking for you i can make a hotfix branch to cherry-pick it.

AndrewWalsh commented 10 months ago

All good, I don't need the fix from my end, thanks for the consideration.