-
Notifications
You must be signed in to change notification settings - Fork 86
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
[WIP] Support router serialization. #90
Closed
+1,219
−938
Closed
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
71f82f3
Support router serialization.
nathanhammond df6f54f
Make this work in non-ES6 browsers.
nathanhammond d8c14b7
Add serialized benchmark.
nathanhammond 942ccff
Fix benchmark.
nathanhammond 2953157
Add trie approach.
nathanhammond 9082ccb
Implement add.
nathanhammond 678b80a
Implement handlersFor, generateQueryString, and parseQueryString.
nathanhammond 47aa7b0
Add in trie walk function.
nathanhammond fc191b0
Make specificity work. Add documentation. Start params work.
nathanhammond 41aa352
Correct glob leaf behavior.
nathanhammond 6d06924
First pass at params.
nathanhammond 40b82a4
Move the trie approach to default.
nathanhammond e9ca2ae
Support query params.
nathanhammond cb82a91
Properly remove handlers.
nathanhammond 8d88f51
Simple param reinsertion for globbing routes.
nathanhammond d4322a9
Run all tests.
nathanhammond 5b44be5
Return null from recognize for misses. Prepend paths with '/'.
nathanhammond e30ee48
Naive fix for empty segments.
nathanhammond 6406030
Throw on generate mismatch.
nathanhammond 85989b6
Write generate.
nathanhammond bb63cb4
Remove the original implementations.
nathanhammond 6204ff6
Stop scanning entire strings.
nathanhammond c132ddb
JIT compacting.
nathanhammond 8e41401
Revert "Stop scanning entire strings."
nathanhammond e812aa4
`push` is much faster than `unshift`.
nathanhammond 1dc7369
Convert matcher to pure loops.
nathanhammond 87d0b2f
Fix generate.
nathanhammond 294d59f
Remove Function#bind.
nathanhammond f6ae1b6
Move to charCodeAt.
nathanhammond 6d99dbe
Include serialization.
nathanhammond 3ef18b6
Achieved JSON.stringify(router) === JSON.stringify(new RouteRecognize…
nathanhammond 8ab70f9
Serialization/hydration works.
nathanhammond 9e10f5f
First pass at adding normalization to the trie approach.
nathanhammond 48673d8
Fix more tests.
nathanhammond cec2193
Breaking apart the monolith.
nathanhammond 8404854
Broken support of addRouteCallback.
nathanhammond 15972cd
Clean up tracing.
nathanhammond 4139fcb
Appears to work for static routes.
nathanhammond c3aba6e
Fix param handling.
nathanhammond 3cfaa9c
Fix removal during compaction.
nathanhammond 1f3e4a4
Fix merging of named routes.
nathanhammond 96f2f5c
Update dist versions.
nathanhammond 4a5e910
Fix leaf node tracking.
nathanhammond 0d50753
Prevent partial static segment matching.
nathanhammond be044e6
Fix boolean logic for popping handlers.
nathanhammond bd58105
Fix dynamic setting for non-handler routes.
nathanhammond f1d4d55
Fix node rejection.
nathanhammond 19d44d9
Temporary workaround for API change introduced by @bantic.
nathanhammond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var RouteRecognizer = require('../../dist/route-recognizer'); | ||
|
||
var router = new RouteRecognizer(); | ||
|
||
router.map(function(match) { | ||
var i = 1000; | ||
while (i--) { | ||
match('/posts/' + i).to('showPost' + i); | ||
} | ||
}); | ||
|
||
var serialized = JSON.parse(router.toJSON()); | ||
|
||
module.exports = { | ||
name: 'Serialized', | ||
fn: function() { | ||
var router = new RouteRecognizer(serialized); | ||
|
||
// Look up time is constant | ||
router.recognize('/posts/1'); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking at the wrong RR instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, rerunning benchmark now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No faster: it wouldn't be, thinking about it. That
new RouteRecognizer(serialized);
is stupidly expensive for some reason.