-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript
.d.ts
file for type checking
Tweaked the test suite into TypeScript for continuous integration and type checking of the public interface
- Loading branch information
1 parent
876222c
commit 78f0a5d
Showing
6 changed files
with
110 additions
and
16 deletions.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
coverage | ||
components | ||
typings |
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
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,53 @@ | ||
declare function pathToRegexp (path: pathToRegexp.Path, options?: pathToRegexp.Options): pathToRegexp.PathRegExp; | ||
declare function pathToRegexp (path: pathToRegexp.Path, keys: pathToRegexp.Token[], options?: pathToRegexp.Options): pathToRegexp.PathRegExp; | ||
|
||
declare namespace pathToRegexp { | ||
export interface PathRegExp extends RegExp { | ||
// An array to be populated with the keys found in the path. | ||
keys: Key[]; | ||
} | ||
|
||
export interface Options { | ||
// When `true` the route will be case sensitive. (default: `false`) | ||
sensitive?: boolean; | ||
// When `false` the trailing slash is optional. (default: `false`) | ||
strict?: boolean; | ||
// When `false` the path will match at the beginning. (default: `true`) | ||
end?: boolean; | ||
} | ||
|
||
/** | ||
* Parse an Express-style path into an array of tokens. | ||
*/ | ||
export function parse (path: string): Token[]; | ||
|
||
/** | ||
* Transforming an Express-style path into a valid path. | ||
*/ | ||
export function compile (path: string): PathFunction; | ||
|
||
/** | ||
* Transform an array of tokens into a path generator function. | ||
*/ | ||
export function tokensToFunction (tokens: Token[]): PathFunction; | ||
|
||
/** | ||
* Transform an array of tokens into a matching regular expression. | ||
*/ | ||
export function tokensToRegExp (tokens: Token[], options?: Options): PathRegExp; | ||
|
||
export interface Key { | ||
name: string | number; | ||
prefix: string; | ||
delimiter: string; | ||
optional: boolean; | ||
repeat: boolean; | ||
pattern: string; | ||
} | ||
|
||
export type Token = string | Key; | ||
export type Path = string | RegExp | Array<string | RegExp>; | ||
export type PathFunction = (data?: Object) => string; | ||
} | ||
|
||
export = pathToRegexp; |
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
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
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,9 @@ | ||
{ | ||
"ambientDependencies": { | ||
"mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617", | ||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#48c1e3c1d6baefa4f1a126f188c27c4fefd36bff" | ||
}, | ||
"devDependencies": { | ||
"chai": "github:typed-typings/npm-chai#01a92b8efc0cfa0ac894d695abd06b8b11e3b75b" | ||
} | ||
} |