{"library":"minimatch","title":"Glob Pattern Matcher","description":"Minimatch is a JavaScript utility library that provides robust glob matching functionality, converting glob expressions into JavaScript `RegExp` objects for efficient pattern matching. It is famously used internally by npm for its file system operations. The current stable version is 10.2.5, with releases typically occurring as needed to address bugs, enhance features, or align with npm's requirements. Key features include support for brace expansion, extended glob matching, globstar (`**`), and Posix character classes (e.g., `[[:alpha:]]`), which are Unicode-aware. A critical aspect of minimatch is its explicit warning regarding Regular Expression Denial of Service (ReDoS) vulnerabilities, advising users to never use untrusted input as glob patterns due to the inherent risks of RegExp-based matching. It also provides specific guidance for Windows users, emphasizing the exclusive use of forward slashes in glob expressions to avoid misinterpretation of backslashes as escape characters.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install minimatch"],"cli":null},"imports":["import { minimatch } from 'minimatch'","const { minimatch } = require('minimatch')","import { Minimatch } from 'minimatch'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { minimatch, Minimatch } from 'minimatch';\n\n// Basic usage\nconsole.log(minimatch('foo/bar/baz.js', 'foo/**/baz.js')); // true\nconsole.log(minimatch('foo/bar/file.txt', '*.txt'));       // false (needs path)\nconsole.log(minimatch('file.txt', '*.txt'));               // true\n\n// With options: debug and nobrace\nconst pattern = 'a/{b,c}/d';\nconst options = { debug: false, nobrace: false };\nconsole.log(minimatch('a/b/d', pattern, options)); // true\nconsole.log(minimatch('a/c/d', pattern, options)); // true\n\n// Using the Minimatch class for pre-compiled patterns\nconst mm = new Minimatch('src/**/*.ts', { matchBase: true });\nconsole.log(mm.match('src/components/button.ts')); // true\nconsole.log(mm.match('dist/index.js'));             // false\n\n// Example with Posix character classes (Unicode aware)\nconsole.log(minimatch('é', '[[:alpha:]]')); // true\nconsole.log(minimatch('123', '[[:digit:]]')); // false\n","lang":"typescript","description":"Demonstrates basic glob matching, usage with options, and pre-compiling patterns with the `Minimatch` class, including Unicode-aware Posix character classes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}