parth 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +18 -34
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -6,13 +6,15 @@
6
6
  [todo](#todo) -
7
7
  [why](#why)
8
8
 
9
+ Now written in TypeScript
10
+
9
11
  ## sample
10
12
 
11
- ```js
13
+ ```ts
12
14
  import Parth from 'parth';
13
15
 
14
16
  const parth = new Parth();
15
- var props = {handle: function(){}};
17
+ const props = { handle: (): void => {} };
16
18
 
17
19
  parth.set('(get|post) /:page/:view', props)
18
20
  .get('get /weekend/baby?query=string#hash user.10.beers now')
@@ -37,14 +39,14 @@ parth.set('(get|post) /:page/:view', props)
37
39
 
38
40
  Parth exports a `Parth` class (default export)
39
41
 
40
- ```js
42
+ ```ts
41
43
  import Parth from 'parth';
42
44
  ```
43
45
 
44
46
  which can take the options below
45
47
 
46
- ```js
47
- var parth = new Parth(options);
48
+ ```ts
49
+ const parth = new Parth(options);
48
50
  ```
49
51
 
50
52
  _options_ type `object`, can be
@@ -52,7 +54,7 @@ _options_ type `object`, can be
52
54
 
53
55
  example:
54
56
 
55
- ```js
57
+ ```ts
56
58
  const parth = new Parth({ defaultRE: /[^\s\/?#]+/ });
57
59
 
58
60
  parth.set('/page/:view') // no regex given after ":view"
@@ -77,8 +79,8 @@ parth.set('/page/:view') // no regex given after ":view"
77
79
 
78
80
  ## parth.set
79
81
 
80
- ```js
81
- function set(string path[, object options])
82
+ ```ts
83
+ parth.set(path, options); // (path: string, options?: object) => this
82
84
  ```
83
85
  This method job is to sanitize `path` and order it with those previously stored.
84
86
 
@@ -91,20 +93,21 @@ _returns_ `this`
91
93
  > NOTE: `options` is deep cloned beforehand to avoid mutation
92
94
 
93
95
  `path` can contain any number of parameters(regexes) in the form
94
- ```js
95
- :param-label(\\regexp(?:here))
96
+ ```ts
97
+ ':param-label(\\regexp(?:here))'
96
98
  ```
97
99
  Any string matching the regular expression below qualifies as a parameter
98
100
 
99
- ````js
100
- /:([-\w]+)(\([^\s]+?[)][?)]*)?/g;
101
- ````
101
+ ```ts
102
+ const paramRE = /:([-\w]+)(\([^\s]+?[)][?)]*)?/g;
103
+ ```
102
104
 
103
105
  [Go to http://regexr.com/](http://regexr.com/3cuqq) and test it out.
104
106
 
105
107
  ## parth.get
106
- ```js
107
- function get(string path)
108
+
109
+ ```ts
110
+ parth.get(path); // (path: string) => ParthResult | null
108
111
  ```
109
112
 
110
113
  Take a string and return a clone of the store object properties
@@ -140,25 +143,6 @@ With [npm](http://npmjs.org)
140
143
 
141
144
  npm install --save parth
142
145
 
143
- ### examples
144
-
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
-
147
- ### test
148
-
149
- npm test
150
-
151
- ```
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
160
- ```
161
-
162
146
  ### license
163
147
 
164
148
  The MIT License (MIT)
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "parth",
3
3
  "main": "dist/index.js",
4
- "version": "5.0.0",
4
+ "version": "5.0.2",
5
5
  "engines": {
6
- "node": ">= 14"
6
+ "node": ">=20"
7
7
  },
8
8
  "author": "Javier Carrillo",
9
9
  "description": "path to regex madness",