tessl install tessl/npm-glob-to-regexp@0.4.0Convert globs to regular expressions
Agent Success
Agent success rate when using this tile
100%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.15x
Baseline
Agent success rate without this tile
87%
Build a simple file path matching utility that filters lists of file paths based on wildcard patterns.
Create a module that exports a function matchPaths which takes an array of file path strings and a pattern string, then returns an array of paths that match the pattern.
The pattern matching should support:
* wildcard which matches zero or more charactersThe function should:
matchPaths(['app.js', 'test.js', 'README.md'], '*.js')
// Returns: ['app.js', 'test.js']
matchPaths(['src/index.js', 'src/utils.js', 'lib/helper.js'], 'src/*.js')
// Returns: ['src/index.js', 'src/utils.js']
matchPaths(['file.txt', 'file.txt.bak', 'data.txt'], '*.txt')
// Returns: ['file.txt', 'data.txt']
matchPaths(['config.json', 'package.json'], 'test-*')
// Returns: []@generates
/**
* Filters an array of file paths based on a wildcard pattern
* @param {string[]} paths - Array of file path strings to filter
* @param {string} pattern - Pattern string with * wildcard support
* @returns {string[]} Array of paths that match the pattern
*/
function matchPaths(paths, pattern) {
// Implementation here
}
module.exports = { matchPaths };const result = matchPaths(['app.js', 'test.js', 'README.md'], '*.js');
// Expected: ['app.js', 'test.js']const result = matchPaths(['src/index.js', 'lib/helper.js', 'src/utils.js'], 'src/*.js');
// Expected: ['src/index.js', 'src/utils.js']const result = matchPaths(['config.json', 'package.json'], 'test-*');
// Expected: []const result = matchPaths(['test-one.js', 'test-two.js', 'main.js'], 'test-*');
// Expected: ['test-one.js', 'test-two.js']Converts glob patterns to regular expressions for pattern matching.