@marvinh/path-to-regexp

Ultra small and fast path to regex generation

Stats

StarsIssuesVersionUpdatedCreatedSize
@marvinh/path-to-regexp
3.1.0a year ago4 years agoMinified + gzip package size for @marvinh/path-to-regexp in KB

Readme

Fast Path To RegExp

Ultra small and super fast library for converting paths to RegExp. Only implements a subset of path-to-regexp.

:myparam -> named parameters, f.ex. /bar/:foo
* -> wildcard catchall, f.ex. /bar/*/foo

Usage

Installation:

# via npm
npm install --save @marvinh/path-to-regexp

# via yarn
yarn add @marvinh/path-to-regexp
import { PathRegExp } from "@marvinh/path-to-regexp";

const Path = new PathRegExp("foo/:bar/*/bob");

// Returns params on match
Path.match("foo/asd/a/");
// -> {
//  matched: "", // The remaining part if any
//  params: { bar: "asd" }
// }

License

MIT, see License file.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.