@reliverse/rematch
Version:
@reliverse/rematch is a high-performance minimal glob matcher, with micromatch-level power, zepto-level size, and reliverse-grade dx.
51 lines (50 loc) • 2.01 kB
TypeScript
import type { State } from "./parse.js";
import * as constants from "./constants.js";
type ScanResult = {
prefix: string;
input: string;
start: number;
base: string;
glob: string;
isBrace: boolean;
isBracket: boolean;
isGlob: boolean;
isExtglob: boolean;
isGlobstar: boolean;
negated: boolean;
[key: string]: any;
};
type Matcher = {
(input: string, returnObject?: boolean): boolean | Record<string, unknown>;
state?: unknown;
};
export type RematchAPI = {
(pattern: string | string[], input: string, options?: Record<string, unknown>): boolean;
(pattern: string | string[], options: Record<string, unknown>): (input: string) => boolean;
test: (input: string, regex: RegExp, options: Record<string, unknown>, extra?: {
glob?: any;
posix?: boolean;
}) => {
isMatch: boolean;
match: any;
output: string;
};
matchBase: (input: string, glob: RegExp | string, options: Record<string, unknown>, posix?: boolean) => boolean;
isMatch: (str: string, patterns: string | string[] | Matcher, options?: Record<string, unknown>) => boolean;
parse(pattern: string, options?: Record<string, unknown>): State;
parse(pattern: readonly string[], options?: Record<string, unknown>): State[];
parse(pattern: string | readonly string[], options?: Record<string, unknown>): State | State[];
scan: (input: string, options?: Record<string, unknown>) => ScanResult;
compileRe: (state: State | {
output: string;
negated?: boolean;
}, options?: Record<string, unknown>, returnOutput?: boolean, returnState?: boolean) => RegExp | string;
makeRe: (input: string, options?: Record<string, unknown>, returnOutput?: boolean, returnState?: boolean) => RegExp | string;
toRegex: (source: string, options?: Record<string, unknown>) => RegExp;
constants: typeof constants;
};
/**
* Expose "@chance/rematch"
*/
declare const rematch: RematchAPI;
export default rematch;