mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
route-recognizer: initial commit
This commit is contained in:
7
route-recognizer/route-recognizer-tests.ts
Normal file
7
route-recognizer/route-recognizer-tests.ts
Normal 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
25
route-recognizer/route-recognizer.d.ts
vendored
Normal 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 }
|
||||
}
|
||||
Reference in New Issue
Block a user