-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
59 lines (54 loc) · 1.23 KB
/
example.ts
File metadata and controls
59 lines (54 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Parth from './src';
const parth = new Parth();
// #set
const input = [
'/',
'/page',
'/page/:number(\\d+)',
'get /',
'get /page',
'get /:page',
'get :page/:view',
'get /:page/:view',
'get /page/:number(\\d+)',
'get /:page(\\w+)/number',
'get /:page(\\w+)/:number(\\d+)',
'(get|post) /page/number',
'(get|post) /:page(\\w+)/number',
'(get|post) /:page(\\w+)/:Number(\\d+)',
'get /page/number',
'(get|post) /:page(\\w+)/:view([^.\\/\\s]+)',
'1',
'2',
'1 2',
'obj.path',
'obj.:path(\\S+).:number(\\d+)',
'obj.:number(\\d+).:path(\\S+)',
'obj.path.:here',
'obj.(prop|path).:here',
':obj.(method|prop).:here',
];
input.forEach((stem) => {
parth.set(stem);
});
// #get
const getInput = [
'1',
'2',
'1 2',
'obj.path.10',
'obj.10.prop',
'obj.10.10',
'array.method.prop',
'get weekend/baby?query=string#hash user.10.beers',
'get /weekend/baby?query=string#hash user.10.beers now',
'get /user/view/#hash',
'post /user/page/photo?query=name&path=tree#hash',
];
console.log(' -- parth.get -- ');
getInput.forEach((stem, index) => {
const result = parth.get(stem);
console.log(' input =', stem);
console.log('result =', result);
console.log(getInput[index + 1] ? ' -- ' : '');
});