t-comm
Version:
专业、稳定、纯粹的工具库
60 lines (59 loc) • 2.09 kB
TypeScript
/**
* Parse a string for the raw tokens.
* @ignore
* @param {string} str
* @param {Object=} options
* @returns {!Array}
*/
declare function parse(str: string, options?: any): (string | {
name: string | number;
prefix: string;
delimiter: any;
optional: boolean;
repeat: boolean;
partial: boolean;
pattern: string;
})[];
/**
* Compile a string to a template function for the path.
* @ignore
* @param {string} str
* @param {Object=} options
* @returns {!function(Object=, Object=)}
*/
declare function compile(str: string, options?: any): (data: any, options: any) => string;
/**
* Expose a method for transforming tokens into the path function.
* @ignore
*/
declare function tokensToFunction(tokens: Array<any>): (data: any, options: any) => string;
/**
* Expose a function for taking tokens and returning a RegExp.
* @ignore
* @param {!Array} tokens
* @param {Array=} keys
* @param {Object=} options
* @returns {!RegExp}
*/
declare function tokensToRegExp(tokens: Array<any>, keys?: Array<any>, options?: any): RegExp;
/**
* Normalize the given path string, returning a regular expression.
*
* An empty array can be passed in for the keys, which will hold the
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
* @ignore
* @param {(string|RegExp|Array)} path
* @param {Array=} keys
* @param {Object=} options
* @returns {!RegExp}
*/
declare function pathToRegexp(path: string | RegExp | Array<any>, keys?: Array<any>, options?: any): any;
declare namespace pathToRegexp {
var parse: typeof import("./path-to-regexp").parse;
var compile: typeof import("./path-to-regexp").compile;
var tokensToFunction: typeof import("./path-to-regexp").tokensToFunction;
var tokensToRegExp: typeof import("./path-to-regexp").tokensToRegExp;
}
export default pathToRegexp;
export { compile, parse, tokensToFunction, tokensToRegExp, };