route-recognizer: initial commit

This commit is contained in:
Dave Keen
2015-06-25 11:56:32 +02:00
parent e1182d56cc
commit 2b244d8041
2 changed files with 32 additions and 0 deletions

View File

@@ -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
route-recognizer/route-recognizer.d.ts vendored Normal file
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 }
}