1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
// Type definitions for to-regex 3.0
// Project: https://github.com/jonschlinkert/to-regex
// Definitions by: Rauli Laine <https://github.com/RauliL>
// Anatoly Pitikin <https://github.com/xapdkop>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace toRegex {
interface Options {
/**
* Generate a regex that will match any string that contains the given
* pattern. By default, regex is strict will only return true for
* exact matches.
*/
contains?: boolean;
/**
* Create a regex that will match everything except the given pattern.
*/
negate?: boolean;
/**
* Adds the i flag, to enable case-insensitive matching.
*/
nocase?: boolean;
/**
* Define the flags you want to use on the generated regex.
*/
flags?: string;
/**
* Generated regex is cached based on the provided string and options.
* As a result, runtime compilation only happens once per pattern (as
* long as options are also the same), which can result in dramatic
* speed improvements.
*
* This also helps with debugging, since adding options and pattern
* are added to the generated regex.
* @default true
*/
cache?: boolean;
/**
* Check the generated regular expression with safe-regex and throw an
* error if the regex is potentially unsafe.
*/
safe?: boolean;
}
/**
* Create a regular expression from the given `pattern` string.
*/
function makeRe(pattern: string | RegExp, options?: Options): RegExp;
}
/**
* Create a regular expression from the given `patterns` string.
*/
declare function toRegex(patterns: string | ReadonlyArray<string> | RegExp, options?: toRegex.Options): RegExp;
export = toRegex;
|