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 file type validation utility that checks if file names match specific allowed extensions or naming patterns.
Create a function called isValidFile that takes a file name (string) and a pattern (string) and returns true if the file name matches the pattern, false otherwise.
The pattern should support:
The function should be case-sensitive by default.
*.{js,ts} should match index.js and app.ts but not style.csstest-*.{spec,test}.js should match test-user.spec.js and test-auth.test.js but not main.test.js{readme,license}.{md,txt} should match readme.md, license.txt, and readme.txt but not changelog.mdisValidFile("component.jsx", "*.{js,jsx}") returns true @testisValidFile("style.css", "*.{js,jsx}") returns false @testisValidFile("config.json", "config.{json,yaml,yml}") returns true @testisValidFile("test-utils.js", "{test,spec}-*.js") returns true @testisValidFile("utils-test.js", "{test,spec}-*.js") returns false @test@generates
/**
* Validates if a file name matches a given pattern with alternative extensions.
*
* @param {string} fileName - The file name to validate.
* @param {string} pattern - The pattern with alternatives (e.g., "*.{js,ts}").
* @returns {boolean} True if the file name matches the pattern, false otherwise.
*/
function isValidFile(fileName, pattern) {
// IMPLEMENTATION HERE
}
module.exports = { isValidFile };Provides pattern matching with support for alternative extensions using curly brace syntax.
@satisfied-by