Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: rewrite library #107

Merged
merged 15 commits into from
Jul 4, 2024
Merged

refactor!: rewrite library #107

merged 15 commits into from
Jul 4, 2024

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jul 3, 2024

This PR rewrites (almost) whole lib from scratch to resolve fundamental issues from the previous/initial version.

Note: As part of this migration, library is being renamed to rou3. (#108)

New tree implementation

A new trie (which is not radix!) is used solve complex scenarios such as #96 and #103 and also allows proper tree DFS search.

New param matching

Previously we were matching params during tree-traverse which was wrong! Because we were not accounting for difference placeholder names from overlapping patterns. This is now done in last step.

Composable utils

The createRouter utility now returns a context instead of object with bound params. The benefit is that we can highly treeshake and optimize final bundle and only import what is needed.

Small behavior changes

Small behavior changes happened particularly for matchAll util.

Native method matching

In radix3, we were using an object in payload to handle methods. This mainly lacks supporting overlaping routes and in h3 we had to workaround using a second matcher! Native method support allow tree searching with fallback.

Benchmarks added

Added new benchmarks that compares to other routers more fairly. Mainly this benchmark makes such to combine all different patterns and also make sure all implementations involve param matching!

~> https://github.com/unjs/rou3/tree/main/benchmark#results

@pi0 pi0 self-assigned this Jul 3, 2024
@pi0 pi0 marked this pull request as draft July 3, 2024 22:29
@pi0 pi0 changed the title refactor!: rewrite tree implementation refactor!: rewrite library Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant