Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript and ES2015 modules #203

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
.nyc_output
coverage
components
dist
dist.es2015
typings
18 changes: 9 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ npm install path-to-regexp --save
```javascript
const pathToRegexp = require('path-to-regexp')

// pathToRegexp(path, keys?, options?)
// pathToRegexp.pathToRegexp(path, keys?, options?)
// pathToRegexp.parse(path)
// pathToRegexp.compile(path)
```
Expand All @@ -38,7 +38,7 @@ const pathToRegexp = require('path-to-regexp')

```javascript
const keys = []
const regexp = pathToRegexp('/foo/:bar', keys)
const regexp = pathToRegexp.pathToRegexp('/foo/:bar', keys)
// regexp = /^\/foo\/([^\/]+?)\/?$/i
// keys = [{ name: 'bar', prefix: '/', delimiter: '/', optional: false, repeat: false, pattern: '[^\\/]+?' }]
```
Expand All @@ -54,7 +54,7 @@ The path argument is used to define parameters and populate the list of keys.
Named parameters are defined by prefixing a colon to the parameter name (`:foo`). By default, the parameter will match until the next prefix (e.g. `[^/]+`).

```js
const regexp = pathToRegexp('/:foo/:bar')
const regexp = pathToRegexp.pathToRegexp('/:foo/:bar')
// keys = [{ name: 'foo', prefix: '/', ... }, { name: 'bar', prefix: '/', ... }]

regexp.exec('/test/route')
Expand All @@ -70,7 +70,7 @@ regexp.exec('/test/route')
Parameters can be suffixed with a question mark (`?`) to make the parameter optional.

```js
const regexp = pathToRegexp('/:foo/:bar?')
const regexp = pathToRegexp.pathToRegexp('/:foo/:bar?')
// keys = [{ name: 'foo', ... }, { name: 'bar', delimiter: '/', optional: true, repeat: false }]

regexp.exec('/test')
Expand All @@ -87,7 +87,7 @@ regexp.exec('/test/route')
Parameters can be suffixed with an asterisk (`*`) to denote a zero or more parameter matches. The prefix is used for each match.

```js
const regexp = pathToRegexp('/:foo*')
const regexp = pathToRegexp.pathToRegexp('/:foo*')
// keys = [{ name: 'foo', delimiter: '/', optional: true, repeat: true }]

regexp.exec('/')
Expand All @@ -102,7 +102,7 @@ regexp.exec('/bar/baz')
Parameters can be suffixed with a plus sign (`+`) to denote a one or more parameter matches. The prefix is used for each match.

```js
const regexp = pathToRegexp('/:foo+')
const regexp = pathToRegexp.pathToRegexp('/:foo+')
// keys = [{ name: 'foo', delimiter: '/', optional: false, repeat: true }]

regexp.exec('/')
Expand All @@ -117,7 +117,7 @@ regexp.exec('/bar/baz')
It is possible to write an unnamed parameter that only consists of a matching group. It works the same as a named parameter, except it will be numerically indexed.

```js
const regexp = pathToRegexp('/:foo/(.*)')
const regexp = pathToRegexp.pathToRegexp('/:foo/(.*)')
// keys = [{ name: 'foo', ... }, { name: 0, ... }]

regexp.exec('/test/route')
Expand All @@ -129,7 +129,7 @@ regexp.exec('/test/route')
All parameters can have a custom regexp, which overrides the default match (`[^/]+`). For example, you can match digits or names in a path:

```js
const regexpNumbers = pathToRegexp('/icon-:foo(\\d+).png')
const regexpNumbers = pathToRegexp.pathToRegexp('/icon-:foo(\\d+).png')
// keys = [{ name: 'foo', ... }]

regexpNumbers.exec('/icon-123.png')
Expand All @@ -138,7 +138,7 @@ regexpNumbers.exec('/icon-123.png')
regexpNumbers.exec('/icon-abc.png')
//=> null

const regexpWord = pathToRegexp('/(user|u)')
const regexpWord = pathToRegexp.pathToRegexp('/(user|u)')
// keys = [{ name: 0, ... }]

regexpWord.exec('/u')
Expand Down
94 changes: 0 additions & 94 deletions index.d.ts

This file was deleted.

Loading