You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parth.set('/page/:view') // no regex given after ":view"
61
59
.get('/page/10/?query=here')
@@ -124,11 +122,13 @@ _return_
124
122
> NOTE: the returned object is a deep copy of the original `options`
125
123
> given in `parth.set` to avoid mutation
126
124
127
-
### parth properties
125
+
### TypeScript
128
126
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
+
```
132
132
133
133
## why
134
134
@@ -142,45 +142,23 @@ With [npm](http://npmjs.org)
142
142
143
143
### examples
144
144
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`).
146
146
147
147
### test
148
148
149
149
npm test
150
150
151
151
```
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
178
160
```
179
161
180
-
### todo
181
-
182
-
- [ ] set support for regexp input
183
-
184
162
### license
185
163
186
164
The MIT License (MIT)
@@ -194,7 +172,5 @@ The above copyright notice and this permission notice shall be included in all c
194
172
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.
0 commit comments