A lightweight JavaScript library for simple wildcard matching with support for negation and multiple patterns.
Matcher is a lightweight JavaScript library that provides simple wildcard matching functionality for strings, supporting patterns with `*` and negation with `!`. It solves the problem of needing flexible string filtering without the complexity of regular expressions or glob patterns, making it ideal for tasks like filtering arrays of strings based on multiple criteria.
JavaScript developers who need to perform basic string matching or filtering in their applications, particularly those working with user input, file paths, or configuration strings where regex is overkill.
Developers choose Matcher for its minimal API, zero dependencies, and performance-focused design, offering a reliable and straightforward solution for wildcard matching that integrates seamlessly into both Node.js and browser environments.
Simple wildcard matching
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The library exposes only two main functions, `matcher` and `isMatch`, with clear usage examples, making it easy to integrate without a steep learning curve.
Supports wildcards with `*`, negation with `!`, and multiple patterns via arrays, enabling complex inclusion/exclusion logic without regex complexity, as shown in the array filtering examples.
Includes a benchmark suite (`npm run bench`), indicating a focus on speed and efficiency for matching operations, which is critical for large datasets.
Offers an optional `caseSensitive` option, allowing precise matching for different scenarios like file names (case-insensitive) or object keys (case-sensitive), as detailed in the API documentation.
Only supports `*` for wildcards and `!` for negation, lacking other common pattern elements like `?` for single characters or character sets, which can restrict more nuanced matching needs.
Does not support glob-like path matching features such as recursive wildcards (`**`) or handling of directory separators, making it less ideal for file system operations compared to dedicated libraries.
While escaping is possible (e.g., `uni\*`), the simple syntax might lead to edge cases or confusion in complex patterns, and there's no built-in support for custom delimiters or advanced escape scenarios.