UNPKG

@reliverse/rematch

Version:

@reliverse/rematch is a high-performance minimal glob matcher, with micromatch-level power, zepto-level size, and reliverse-grade dx.

49 lines (48 loc) 1.34 kB
type Token = { value: string; depth: number; isGlob: boolean; backslashes?: boolean; isBrace?: boolean; isBracket?: boolean; isExtglob?: boolean; isGlobstar?: boolean; negated?: boolean; isPrefix?: boolean; }; type State = { prefix: string; input: string; start: number; base: string; glob: string; isBrace: boolean; isBracket: boolean; isGlob: boolean; isExtglob: boolean; isGlobstar: boolean; negated: boolean; negatedExtglob: boolean; maxDepth?: number; tokens?: Token[]; slashes?: number[]; parts?: string[]; }; /** * Quickly scans a glob pattern and returns an object with a handful of * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists), * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not * with `!(`) and `negatedExtglob` (true if the path starts with `!(`). * * ```js * import rematch from '@chance/rematch'; * console.log(rematch.scan('foo/bar/*.js')); * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' } * ``` * @param {String} `str` * @param {Object} `options` * @return {Object} Returns an object with tokens and regex source string. * @api public */ declare const scan: (input: any, options: any) => State; export default scan;