Skip to content

Commit 2b244d8

Browse files
committed
route-recognizer: initial commit
1 parent e1182d5 commit 2b244d8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="route-recognizer.d.ts" />
2+
3+
import RouteRecognizer = require('route-recognizer')
4+
5+
var router = new RouteRecognizer<string>();
6+
router.add([{ path: "/posts", handler: "i am the handler" }]);
7+
var result = router.recognize("/posts");
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Type definitions for route-recognizer
2+
// Project: https://github.com/tildeio/route-recognizer
3+
// Definitions by: Dave Keen <http://www.keendevelopment.ch>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
declare module "route-recognizer" {
7+
8+
class RouteRecognizer<H> {
9+
constructor()
10+
add: (routes: Route<H>[]) => void
11+
recognize: (path: string) => MatchedRoute<H>[]
12+
}
13+
14+
interface Route<H> {
15+
path: string
16+
handler: H
17+
}
18+
19+
export = RouteRecognizer
20+
}
21+
22+
interface MatchedRoute<H> {
23+
handler: H
24+
params: { [key: string]: string }
25+
}

0 commit comments

Comments
 (0)