Skip to content

Commit d6a30a1

Browse files
committed
Update README.md
1 parent 1c0963b commit d6a30a1

1 file changed

Lines changed: 22 additions & 46 deletions

File tree

README.md

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
[todo](#todo) -
77
[why](#why)
88

9-
[![build][badge-build]][x-travis]
10-
119
## sample
1210

1311
```js
14-
var Parth = require('parth');
12+
import Parth from 'parth';
1513

16-
var parth = new Parth();
14+
const parth = new Parth();
1715
var props = {handle: function(){}};
1816

1917
parth.set('(get|post) /:page/:view', props)
@@ -37,11 +35,11 @@ parth.set('(get|post) /:page/:view', props)
3735

3836
## documentation
3937

40-
The `module.exports` a `Parth` constructor
38+
Parth exports a `Parth` class (default export)
4139

42-
````js
43-
var Parth = require('parth');
44-
````
40+
```js
41+
import Parth from 'parth';
42+
```
4543

4644
which can take the options below
4745

@@ -55,7 +53,7 @@ _options_ type `object`, can be
5553
example:
5654

5755
```js
58-
var parth = new Parth({ defaultRE: /[^\s\/?#]+/ });
56+
const parth = new Parth({ defaultRE: /[^\s\/?#]+/ });
5957

6058
parth.set('/page/:view') // no regex given after ":view"
6159
.get('/page/10/?query=here')
@@ -124,11 +122,13 @@ _return_
124122
> NOTE: the returned object is a deep copy of the original `options`
125123
> given in `parth.set` to avoid mutation
126124

127-
### parth properties
125+
### TypeScript
128126

129-
- `parth.store`: all paths set for match are here
130-
- `parth.regex`: array of carefully ordered regexes
131-
- `parth.regex.master`: regex aggregating all learned
127+
Parth is written in TypeScript and ships with type definitions. Import types as needed:
128+
129+
```ts
130+
import Parth, { ParthOptions, ParthResult } from 'parth';
131+
```
132132

133133
## why
134134

@@ -142,45 +142,23 @@ With [npm](http://npmjs.org)
142142

143143
### examples
144144

145-
Run the [`example.js`](example.js) file.
145+
Run the [`example.ts`](example.ts) file: `npx tsx example.ts` (or `npm run dist` then run with Node after changing the import to `./dist`).
146146

147147
### test
148148

149149
npm test
150150

151151
```
152-
➜ parth (master) ✓ npm t
153-
parth
154-
paths
155-
✓ object
156-
✓ raw object paths
157-
✓ unix paths
158-
✓ raw unix paths
159-
✓ urls
160-
✓ raw urls
161-
✓ urls: querystring is stripped
162-
✓ urls: hash is stripped
163-
✓ urls: parameters are not mistaken as querystrings
164-
✓ space separated paths
165-
✓ raw, space separated paths
166-
✓ unix, object and url paths together
167-
✓ raw: unix, object and urls paths together
168-
params
169-
✓ can be given as a string regex
170-
✓ will contain all parameter keys at _
171-
✓ parameter values should be at params
172-
notFound
173-
✓ should be false for perfect match
174-
✓ should have what is left of the path
175-
176-
177-
18 passing (16ms)
152+
➜ parth npm test
153+
PASS test/paths.test.ts
154+
PASS test/params.test.ts
155+
PASS test/options.test.ts
156+
PASS test/notFound.test.ts
157+
158+
Test Suites: 4 passed, 4 total
159+
Tests: 20 passed, 20 total
178160
```
179161

180-
### todo
181-
182-
- [ ] set support for regexp input
183-
184162
### license
185163

186164
The MIT License (MIT)
@@ -194,7 +172,5 @@ The above copyright notice and this permission notice shall be included in all c
194172
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
195173

196174
[x-npm]: https://npmjs.org/package/parth
197-
[x-travis]: https://travis-ci.org/stringparser/parth/builds
198-
[badge-build]: http://img.shields.io/travis/stringparser/parth/master.svg?style=flat-square
199175
[badge-version]: http://img.shields.io/npm/v/parth.svg?style=flat-square
200176
[badge-downloads]: http://img.shields.io/npm/dm/parth.svg?style=flat-square

0 commit comments

Comments
 (0)