picomatch-rs
v0.1.0
Published
Rust port of picomatch - fast glob matching
Readme
picomatch-rs
Rust port of micromatch/picomatch — a fast and accurate glob matching library.
Features
- Full API parity with the original picomatch
- Zero-dependency Rust core for maximum performance
- Node.js native addon via napi-rs for seamless JS/TS integration
- Dual entry: use as a Rust crate or as an npm package
Installation
Node.js
npm install picomatch-rsRust
[dependencies]
rust-picomatch = { git = "https://github.com/your-org/picomatch-rs" }Usage
Node.js (CommonJS)
const pm = require('picomatch-rs');
pm.isMatch('foo/bar', 'foo/*'); // true
pm.isMatch('.foo', '*.foo', { dot: true }); // true
const matcher = pm.picomatch('*.js');
matcher('index.js'); // true
const state = pm.scan('./src/**/*.ts');
// { base: 'src', glob: '**/*.ts', isGlob: true, ... }Node.js (ESM)
import pm, { isMatch, makeRe, parse, scan } from 'picomatch-rs';
isMatch('foo/bar', 'foo/*'); // true
const re = makeRe('f*'); // /^(?:f[^/]*?)$/Rust
use rust_picomatch::is_match;
assert!(is_match("foo/bar", "foo/*", None));API
| Function | Description |
|----------|-------------|
| isMatch(input, pattern, options?) | Test if a string matches a glob pattern |
| makeRe(pattern, options?) | Compile a pattern to a RegExp |
| parse(pattern, options?) | Parse a pattern and return metadata |
| scan(input, options?) | Scan a glob and extract base path / glob parts |
| picomatch(glob, options?) | Return a reusable matcher function |
Options
All picomatch options are supported:
dot— match dotfilesnocase— case-insensitive matchingbash— bash-like behaviorcapture— capture groupsposix— POSIX bracket expressionsstrictSlashes— strict slash handlingnoextglob— disable extglobsnobrace— disable brace expansionnoglobstar— disable**maxLength— max pattern lengthmaxExtglobRecursion— max extglob recursion depth- ...and more
Benchmarks
Coming soon.
License
MIT
