Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
83
Build a file path matching utility that handles different path prefixes consistently. The utility should match file paths against glob patterns while automatically normalizing various path prefixes.
Your implementation should:
./ or ~/) and matches them against glob patterns*.js, src/**/*.ts, etc.When matching paths:
./ should have the prefix removed before matching (e.g., ./index.js becomes index.js)~/ should have the prefix removed before matching (e.g., ~/src/file.js becomes src/file.js)Create a module that exports a function createPathMatcher(pattern) which returns a matcher function. The matcher function should accept a file path and return true if it matches the pattern, false otherwise.
@generates
/**
* Creates a path matcher that normalizes path prefixes before matching
* @param {string} pattern - The glob pattern to match against
* @returns {Function} A matcher function that takes a path and returns boolean
*/
function createPathMatcher(pattern) {
// IMPLEMENTATION HERE
}
module.exports = { createPathMatcher };*.js pattern matches ./index.js and ~/index.js as index.js @testsrc/**/*.ts pattern matches ./src/lib/util.ts and ~/src/lib/util.ts after normalization @testindex.js are matched as-is @testProvides glob pattern matching support.
Install with Tessl CLI
npx tessl i tessl/npm-picomatchevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10