outmatch
Version:
An extremely fast and lightweight glob-matching library with advanced features
47 lines (46 loc) • 1.34 kB
TypeScript
interface OutmatchOptions {
separator?: boolean | string;
flags?: string;
excludeDot?: boolean;
"!"?: boolean;
"?"?: boolean;
"*"?: boolean;
"**"?: boolean;
"[]"?: boolean;
"()"?: boolean;
"{}"?: boolean;
}
interface isMatch {
/**
* Tests if a sample string matches the pattern(s)
*
* ```js
* isMatch('foo') //=> true
* ```
*/
(sample: string): boolean;
/** The compiled regular expression */
regexp: RegExp;
/** The original pattern or array of patterns that was used to compile the RegExp */
pattern: string | string[];
/** The options that were used to compile the RegExp */
options: OutmatchOptions;
}
declare function isMatch(regexp: RegExp, sample: string): boolean;
/**
* Compiles one or more glob patterns into a RegExp and returns an isMatch function.
* The isMatch function takes a sample string as its only argument and returns true
* if the string matches the pattern(s).
*
* ```js
* outmatch('src/*.js')('src/index.js') //=> true
* ```
*
* ```js
* const isMatch = outmatch('*.example.com', '.')
* isMatch('foo.example.com') //=> true
* isMatch('foo.bar.com') //=> false
* ```
*/
declare function outmatch(pattern: string | string[], options?: OutmatchOptions | string | boolean): isMatch;
export = outmatch;