A tiny (394B) utility that converts route patterns like '/users/:id' into regular expressions.
regexparam is a tiny JavaScript utility that converts route patterns (e.g., '/users/:id') into regular expressions. It solves the problem of parsing dynamic URL segments in routing libraries with minimal code overhead. It's designed as a limited, lightweight alternative to more comprehensive solutions like path-to-regexp.
JavaScript developers building routers for servers or clients who need a minimal, fast pattern parser without the bulk of full routing libraries.
Developers choose regexparam for its extremely small size (394B) and focused functionality, making it ideal for performance-sensitive projects where every byte counts, or as a building block for custom routing solutions.
A tiny (394B) utility that converts route patterns into RegExp. Limited alternative to path-to-regexp 🙇♂️
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
At only 394 bytes, regexparam adds negligible weight to bundles, which is crucial for performance-sensitive web applications where every byte counts.
Provides parse to convert patterns to RegExp and inject to populate patterns with values, making it easy to integrate into custom routing logic without complexity.
Accepts existing RegExp objects directly without modification, allowing developers to use custom regex patterns and named capture groups for fine-tuned control.
Available as CommonJS, ES Module, and UMD builds, supporting various JavaScript environments including Node.js, browsers, and Deno, as shown in the README.
Only handles basic operators like static routes, parameters, and wildcards, missing advanced features such as nested routes or arrays that libraries like path-to-regexp offer.
Does not create a keys dictionary; developers must write custom code to extract parameters from regex matches, as demonstrated in the README's exec function, adding boilerplate.
The parse function only accepts string patterns, not objects or other formats, limiting flexibility for complex or dynamic route definitions that might need programmatic generation.
regexparam is an open-source alternative to the following products: