{"name":"glob-to-regex.js","version":"1.0.1","keywords":["glob","regex","regexp","pattern","matcher","path","filesystem","wildcard"],"author":{"url":"https://github.com/streamich","name":"streamich"},"license":"Apache-2.0","_id":"glob-to-regex.js@1.0.1","maintainers":[{"name":"streamich","email":"vadimsdaleckis@gmail.com"}],"homepage":"https://github.com/streamich/glob-to-regex","bugs":{"url":"https://github.com/streamich/glob-to-regex/issues"},"dist":{"shasum":"f71cc9cb8441471a9318626160bc8a35e1306b21","tarball":"http://registry-npm.ywwl.com/glob-to-regex.js/download/glob-to-regex.js-1.0.1.tgz","fileCount":4,"integrity":"sha512-CG/iEvgQqfzoVsMUbxSJcwbG2JwyZ3naEqPkeltwl0BSS8Bp83k3xlGms+0QdWFUAwV+uvo80wNswKF6FWEkKg==","signatures":[{"sig":"MEQCIGh/D2XcALiLWI9oW6ClNB3xKei8GdsY2wF+TE95pW7nAiBYo6i2f68pV7daQYSVCUTlTxBUw5tMl2/2hPkaOfWl7g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11378,"size":3889,"noattachment":false,"key":"/glob-to-regex.js/-/glob-to-regex.js-1.0.1.tgz"},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"node":">=10.0"},"funding":{"url":"https://github.com/sponsors/streamich","type":"github"},"gitHead":"d1522da4c68c3818a20bd9dde3eaf07c88285b3e","scripts":{"lint":"biome lint ./src","test":"vitest ./src","build":"tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib","clean":"npx rimraf@6.0.1 lib typedocs coverage gh-pages yarn-error.log","format":"biome format ./src","typedoc":"npx typedoc@0.25.13 --tsconfig tsconfig.build.json","coverage":"vitest run --coverage","lint:fix":"biome lint --apply ./src","format:fix":"biome format --write ./src","build:pages":"npx rimraf@6.0.1 gh-pages && mkdir -p gh-pages && cp -r typedocs/* gh-pages && cp -r coverage gh-pages/coverage","deploy:pages":"gh-pages -d gh-pages","publish-coverage-and-typedocs":"yarn typedoc && yarn coverage && yarn build:pages && yarn deploy:pages"},"typings":"lib/index.d.ts","_npmUser":{"name":"streamich","email":"vadimsdaleckis@gmail.com"},"repository":{"url":"git+https://github.com/streamich/glob-to-regex.git","type":"git"},"_npmVersion":"11.5.1","description":"Transform GLOB patterns to JavaScript regular expressions for fast file path matching.","directories":{},"_nodeVersion":"24.6.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"yarn@4.9.3","devDependencies":{"tslib":"^2.8.1","vitest":"^3.2.4","typescript":"^5.8.3","config-galore":"^1.0.0","@biomejs/biome":"^2.1.2","@vitest/coverage-v8":"^3.2.4"},"peerDependencies":{"tslib":"2"},"_npmOperationalInternal":{"tmp":"tmp/glob-to-regex.js_1.0.1_1756033666286_0.386317580852928","host":"s3://npm-registry-packages-npm-production"},"readme":"# glob-to-regex.js\n\nTransform GLOB patterns to JavaScript regular expressions for fast file path matching.\n\nThis tiny library converts familiar shell-style glob patterns like `**/*.ts` or `src/{a,b}/**/*.js` into JavaScript `RegExp` objects and provides a convenient matcher utility.\n\n## Install\n\n```bash\nyarn add glob-to-regex.js\n# or\nnpm i glob-to-regex.js\n```\n\n## Quick start\n\n```ts\nimport {toRegex, toMatcher} from 'glob-to-regex.js';\n\n// Build a RegExp from a glob\nconst re = toRegex('src/**/test.ts');\nre.test('src/a/b/test.ts'); // true\nre.test('src/test.ts');     // true\nre.test('src/test.tsx');    // false\n\n// Build a predicate function from a pattern or an array of patterns\nconst match = toMatcher(['**/*.ts', '!**/*.d.ts']); // negative patterns are not special; use a RegExp if needed\nmatch('index.ts');    // true\nmatch('types.d.ts');  // true (negation is not parsed specially)\n```\n\n## API\n\n- toRegex(pattern: string): RegExp\n\t- Converts a glob pattern to an anchored regular expression (`^...$`).\n\n- toMatcher(pattern: string | RegExp | Array<string | RegExp>): (path: string) => boolean\n\t- Accepts a glob string, a RegExp, or an array of them. If given an array, it returns true if any item matches (logical OR, short-circuited).\n\t- Strings starting with `/` and ending with `/flags?` are treated as regular expressions (e.g. `\"/\\\\.test\\\\.ts$/\"`).\n\n## Supported glob features\n\n- `/` separates path segments\n- `*` matches zero or more characters within a single segment (does not cross `/`)\n- `?` matches exactly one character within a single segment\n- `**` matches across path segments, including none\n- `{a,b,c}` alternation groups (no nesting). Each item inside can itself contain glob syntax\n- Character classes: `[abc]`, `[a-z]`, `[!a-z]`, `[!abc]`\n- **Extended globbing** (when `extglob: true` option is set):\n  - `?(pattern-list)` matches zero or one occurrence of the given patterns\n  - `*(pattern-list)` matches zero or more occurrences of the given patterns\n  - `+(pattern-list)` matches one or more occurrences of the given patterns\n  - `@(pattern-list)` matches exactly one of the given patterns\n  - `!(pattern-list)` matches anything except one of the given patterns\n  - Pattern lists use `|` as separator (e.g., `@(jpg|png|gif)`)\n\nNotes:\n- The produced RegExp is anchored at start and end (`^...$`).\n- Character classes are copied through to the output regex. Use standard JavaScript class syntax.\n- Brace groups are not nestable. If an unmatched `{` is found, it is treated literally.\n\n## Examples\n\n```ts\ntoRegex('a/b/c.txt').test('a/b/c.txt'); // true\ntoRegex('a/*.txt').test('a/file.txt');  // true\ntoRegex('a/*.txt').test('a/x/y.txt');   // false\ntoRegex('file?.js').test('file1.js');   // true\ntoRegex('src/**/test.ts').test('src/a/b/test.ts'); // true\ntoRegex('assets/**').test('assets/a/b.png');       // true\ntoRegex('*.{html,txt}').test('page.html');         // true\ntoRegex('src/{a,b}/**/*.ts').test('src/b/x/y.ts'); // true\ntoRegex('file[0-9].txt').test('file5.txt');        // true\ntoRegex('file[!0-9].txt').test('filea.txt');       // true\ntoRegex('**/*.[jt]s{,x}').test('dir/a/b.jsx');     // true\n\n// Extended globbing examples\ntoRegex('file?(s).txt', {extglob: true}).test('file.txt');  // true\ntoRegex('file?(s).txt', {extglob: true}).test('files.txt'); // true\ntoRegex('file.@(jpg|png|gif)', {extglob: true}).test('file.jpg'); // true\ntoRegex('/var/log/!(*.gz)', {extglob: true}).test('/var/log/syslog'); // true\ntoRegex('/var/log/!(*.gz)', {extglob: true}).test('/var/log/error.log.gz'); // false\ntoRegex('src/**/!(*.test).js', {extglob: true}).test('src/app.test.js'); // false\ntoRegex('src/**/!(*.test).js', {extglob: true}).test('src/index.js'); // true\n```\n\n## TypeScript\n\nTypes are bundled. The library targets modern Node.js and browsers.\n\n## Performance\n\n`toRegex` performs a single pass over the pattern and creates a native RegExp. Matching is then performed by V8's highly optimized engine.\n\n## Limitations\n\n- Brace groups are not nested.\n- Negated globs like `!**/*.d.ts` are not parsed specially. If you need exclusion, combine multiple matchers or filter results separately.\n\n## License\n\nApache-2.0 © streamich\n\n","publish_time":1756033666470,"_cnpm_publish_time":1756033666470,"dist-tags":{"latest":"1.3.1"}}