Merge pull request #4748 from ccapndave/route-recognizer

route-recognizer: initial commit
This commit is contained in:
Masahiro Wakame
2015-06-27 14:11:04 +09:00
2 changed files with 32 additions and 0 deletions
@@ -0,0 +1,7 @@
/// <reference path="route-recognizer.d.ts" />
import RouteRecognizer = require('route-recognizer')
var router = new RouteRecognizer<string>();
router.add([{ path: "/posts", handler: "i am the handler" }]);
var result = router.recognize("/posts");
+25
View File
@@ -0,0 +1,25 @@
// Type definitions for route-recognizer
// Project: https://github.com/tildeio/route-recognizer
// Definitions by: Dave Keen <http://www.keendevelopment.ch>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "route-recognizer" {
class RouteRecognizer<H> {
constructor()
add: (routes: Route<H>[]) => void
recognize: (path: string) => MatchedRoute<H>[]
}
interface Route<H> {
path: string
handler: H
}
export = RouteRecognizer
}
interface MatchedRoute<H> {
handler: H
params: { [key: string]: string }
}