parth 5.0.1 → 5.0.3

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 +26 -42
  2. package/package.json +6 -3
package/README.md CHANGED
@@ -1,18 +1,26 @@
1
1
  # parth [![NPM version][badge-version]][x-npm] [![downloads][badge-downloads]][x-npm]
2
2
 
3
3
  [documentation](#documentation) -
4
- [examples](#examples) -
5
4
  [install](#install) -
6
- [todo](#todo) -
7
5
  [why](#why)
8
6
 
7
+ Now written in TypeScript
8
+
9
+ ## install
10
+
11
+ With [npm](http://npmjs.org)
12
+
13
+ npm i -SE parth
14
+
9
15
  ## sample
10
16
 
11
- ```js
17
+ > See [./examples.ts](./example.ts) for more
18
+
19
+ ```ts
12
20
  import Parth from 'parth';
13
21
 
14
22
  const parth = new Parth();
15
- var props = {handle: function(){}};
23
+ const props = { handle: (): void => {} };
16
24
 
17
25
  parth.set('(get|post) /:page/:view', props)
18
26
  .get('get /weekend/baby?query=string#hash user.10.beers now')
@@ -37,14 +45,14 @@ parth.set('(get|post) /:page/:view', props)
37
45
 
38
46
  Parth exports a `Parth` class (default export)
39
47
 
40
- ```js
48
+ ```ts
41
49
  import Parth from 'parth';
42
50
  ```
43
51
 
44
52
  which can take the options below
45
53
 
46
- ```js
47
- var parth = new Parth(options);
54
+ ```ts
55
+ const parth = new Parth(options);
48
56
  ```
49
57
 
50
58
  _options_ type `object`, can be
@@ -52,7 +60,7 @@ _options_ type `object`, can be
52
60
 
53
61
  example:
54
62
 
55
- ```js
63
+ ```ts
56
64
  const parth = new Parth({ defaultRE: /[^\s\/?#]+/ });
57
65
 
58
66
  parth.set('/page/:view') // no regex given after ":view"
@@ -77,8 +85,8 @@ parth.set('/page/:view') // no regex given after ":view"
77
85
 
78
86
  ## parth.set
79
87
 
80
- ```js
81
- function set(string path[, object options])
88
+ ```ts
89
+ parth.set(path, options); // (path: string, options?: object) => this
82
90
  ```
83
91
  This method job is to sanitize `path` and order it with those previously stored.
84
92
 
@@ -91,20 +99,21 @@ _returns_ `this`
91
99
  > NOTE: `options` is deep cloned beforehand to avoid mutation
92
100
 
93
101
  `path` can contain any number of parameters(regexes) in the form
94
- ```js
95
- :param-label(\\regexp(?:here))
102
+ ```ts
103
+ ':param-label(\\regexp(?:here))'
96
104
  ```
97
105
  Any string matching the regular expression below qualifies as a parameter
98
106
 
99
- ````js
100
- /:([-\w]+)(\([^\s]+?[)][?)]*)?/g;
101
- ````
107
+ ```ts
108
+ const paramRE = /:([-\w]+)(\([^\s]+?[)][?)]*)?/g;
109
+ ```
102
110
 
103
111
  [Go to http://regexr.com/](http://regexr.com/3cuqq) and test it out.
104
112
 
105
113
  ## parth.get
106
- ```js
107
- function get(string path)
114
+
115
+ ```ts
116
+ parth.get(path); // (path: string) => ParthResult | null
108
117
  ```
109
118
 
110
119
  Take a string and return a clone of the store object properties
@@ -134,31 +143,6 @@ import Parth, { ParthOptions, ParthResult } from 'parth';
134
143
 
135
144
  I need it for the [gulp-runtime](https://github.com/stringparser/gulp-runtime) module.
136
145
 
137
- ## install
138
-
139
- With [npm](http://npmjs.org)
140
-
141
- npm install --save parth
142
-
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,13 +1,16 @@
1
1
  {
2
2
  "name": "parth",
3
3
  "main": "dist/index.js",
4
- "version": "5.0.1",
4
+ "version": "5.0.3",
5
5
  "engines": {
6
6
  "node": ">=20"
7
7
  },
8
8
  "author": "Javier Carrillo",
9
9
  "description": "path to regex madness",
10
- "repository": "stringparser/parth",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/stringparser/parth.git"
13
+ },
11
14
  "homepage": "https://github.com/stringparser/parth",
12
15
  "bugs": {
13
16
  "url": "https://github.com/stringparser/parth/issues"
@@ -17,7 +20,7 @@
17
20
  "test": "jest",
18
21
  "posttest": "npm run verify:publish",
19
22
  "dist": "tsc",
20
- "prepublishOnly": "npm run dist",
23
+ "prepublishOnly": "npm run test && npm run dist",
21
24
  "verify:publish": "bash test/verify-publish/test.sh"
22
25
  },
23
26
  "devDependencies": {