Skip to content

Commit cb7aefc

Browse files
Preet ShihnPreet Shihn
authored andcommitted
some refactoring
1 parent 6cb5a3e commit cb7aefc

File tree

10 files changed

+149
-149
lines changed

10 files changed

+149
-149
lines changed

bin/path.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ function isType(token, type) {
22
return token.type === type;
33
}
44
const PARAMS = {
5-
A: { length: 7 },
6-
a: { length: 7 },
7-
C: { length: 6 },
8-
c: { length: 6 },
9-
H: { length: 1 },
10-
h: { length: 1 },
11-
L: { length: 2 },
12-
l: { length: 2 },
13-
M: { length: 2 },
14-
m: { length: 2 },
15-
Q: { length: 4 },
16-
q: { length: 4 },
17-
S: { length: 4 },
18-
s: { length: 4 },
19-
T: { length: 4 },
20-
t: { length: 2 },
21-
V: { length: 1 },
22-
v: { length: 1 },
23-
Z: { length: 0 },
24-
z: { length: 0 }
5+
A: 7,
6+
a: 7,
7+
C: 6,
8+
c: 6,
9+
H: 1,
10+
h: 1,
11+
L: 2,
12+
l: 2,
13+
M: 2,
14+
m: 2,
15+
Q: 4,
16+
q: 4,
17+
S: 4,
18+
s: 4,
19+
T: 4,
20+
t: 2,
21+
V: 1,
22+
v: 1,
23+
Z: 0,
24+
z: 0
2525
};
2626
class ParsedPath {
2727
constructor(d) {
@@ -66,7 +66,7 @@ class ParsedPath {
6666
if (mode === 'BOD') {
6767
if (token.text === 'M' || token.text === 'm') {
6868
index++;
69-
param_length = PARAMS[token.text].length;
69+
param_length = PARAMS[token.text];
7070
mode = token.text;
7171
}
7272
else {
@@ -76,11 +76,11 @@ class ParsedPath {
7676
}
7777
else {
7878
if (isType(token, this.NUMBER)) {
79-
param_length = PARAMS[mode].length;
79+
param_length = PARAMS[mode];
8080
}
8181
else {
8282
index++;
83-
param_length = PARAMS[token.text].length;
83+
param_length = PARAMS[token.text];
8484
mode = token.text;
8585
}
8686
}
@@ -95,7 +95,7 @@ class ParsedPath {
9595
return;
9696
}
9797
}
98-
if (PARAMS[mode]) {
98+
if (typeof PARAMS[mode] === 'number') {
9999
const segment = { key: mode, data: params };
100100
this.segments.push(segment);
101101
index += param_length;

dist/rough.es5.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ var rough = (function () {
5959
return token.type === type;
6060
}
6161
var PARAMS = {
62-
A: { length: 7 },
63-
a: { length: 7 },
64-
C: { length: 6 },
65-
c: { length: 6 },
66-
H: { length: 1 },
67-
h: { length: 1 },
68-
L: { length: 2 },
69-
l: { length: 2 },
70-
M: { length: 2 },
71-
m: { length: 2 },
72-
Q: { length: 4 },
73-
q: { length: 4 },
74-
S: { length: 4 },
75-
s: { length: 4 },
76-
T: { length: 4 },
77-
t: { length: 2 },
78-
V: { length: 1 },
79-
v: { length: 1 },
80-
Z: { length: 0 },
81-
z: { length: 0 }
62+
A: 7,
63+
a: 7,
64+
C: 6,
65+
c: 6,
66+
H: 1,
67+
h: 1,
68+
L: 2,
69+
l: 2,
70+
M: 2,
71+
m: 2,
72+
Q: 4,
73+
q: 4,
74+
S: 4,
75+
s: 4,
76+
T: 4,
77+
t: 2,
78+
V: 1,
79+
v: 1,
80+
Z: 0,
81+
z: 0
8282
};
8383

8484
var ParsedPath = function () {
@@ -128,18 +128,18 @@ var rough = (function () {
128128
if (mode === 'BOD') {
129129
if (token.text === 'M' || token.text === 'm') {
130130
index++;
131-
param_length = PARAMS[token.text].length;
131+
param_length = PARAMS[token.text];
132132
mode = token.text;
133133
} else {
134134
this.parseData('M0,0' + d);
135135
return;
136136
}
137137
} else {
138138
if (isType(token, this.NUMBER)) {
139-
param_length = PARAMS[mode].length;
139+
param_length = PARAMS[mode];
140140
} else {
141141
index++;
142-
param_length = PARAMS[token.text].length;
142+
param_length = PARAMS[token.text];
143143
mode = token.text;
144144
}
145145
}
@@ -153,7 +153,7 @@ var rough = (function () {
153153
return;
154154
}
155155
}
156-
if (PARAMS[mode]) {
156+
if (typeof PARAMS[mode] === 'number') {
157157
var segment = { key: mode, data: params };
158158
this.segments.push(segment);
159159
index += param_length;

dist/rough.es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rough.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ var rough = (function () {
55
return token.type === type;
66
}
77
const PARAMS = {
8-
A: { length: 7 },
9-
a: { length: 7 },
10-
C: { length: 6 },
11-
c: { length: 6 },
12-
H: { length: 1 },
13-
h: { length: 1 },
14-
L: { length: 2 },
15-
l: { length: 2 },
16-
M: { length: 2 },
17-
m: { length: 2 },
18-
Q: { length: 4 },
19-
q: { length: 4 },
20-
S: { length: 4 },
21-
s: { length: 4 },
22-
T: { length: 4 },
23-
t: { length: 2 },
24-
V: { length: 1 },
25-
v: { length: 1 },
26-
Z: { length: 0 },
27-
z: { length: 0 }
8+
A: 7,
9+
a: 7,
10+
C: 6,
11+
c: 6,
12+
H: 1,
13+
h: 1,
14+
L: 2,
15+
l: 2,
16+
M: 2,
17+
m: 2,
18+
Q: 4,
19+
q: 4,
20+
S: 4,
21+
s: 4,
22+
T: 4,
23+
t: 2,
24+
V: 1,
25+
v: 1,
26+
Z: 0,
27+
z: 0
2828
};
2929
class ParsedPath {
3030
constructor(d) {
@@ -69,7 +69,7 @@ var rough = (function () {
6969
if (mode === 'BOD') {
7070
if (token.text === 'M' || token.text === 'm') {
7171
index++;
72-
param_length = PARAMS[token.text].length;
72+
param_length = PARAMS[token.text];
7373
mode = token.text;
7474
}
7575
else {
@@ -79,11 +79,11 @@ var rough = (function () {
7979
}
8080
else {
8181
if (isType(token, this.NUMBER)) {
82-
param_length = PARAMS[mode].length;
82+
param_length = PARAMS[mode];
8383
}
8484
else {
8585
index++;
86-
param_length = PARAMS[token.text].length;
86+
param_length = PARAMS[token.text];
8787
mode = token.text;
8888
}
8989
}
@@ -98,7 +98,7 @@ var rough = (function () {
9898
return;
9999
}
100100
}
101-
if (PARAMS[mode]) {
101+
if (typeof PARAMS[mode] === 'number') {
102102
const segment = { key: mode, data: params };
103103
this.segments.push(segment);
104104
index += param_length;

dist/rough.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rough.umd.es5.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@
6262
return token.type === type;
6363
}
6464
var PARAMS = {
65-
A: { length: 7 },
66-
a: { length: 7 },
67-
C: { length: 6 },
68-
c: { length: 6 },
69-
H: { length: 1 },
70-
h: { length: 1 },
71-
L: { length: 2 },
72-
l: { length: 2 },
73-
M: { length: 2 },
74-
m: { length: 2 },
75-
Q: { length: 4 },
76-
q: { length: 4 },
77-
S: { length: 4 },
78-
s: { length: 4 },
79-
T: { length: 4 },
80-
t: { length: 2 },
81-
V: { length: 1 },
82-
v: { length: 1 },
83-
Z: { length: 0 },
84-
z: { length: 0 }
65+
A: 7,
66+
a: 7,
67+
C: 6,
68+
c: 6,
69+
H: 1,
70+
h: 1,
71+
L: 2,
72+
l: 2,
73+
M: 2,
74+
m: 2,
75+
Q: 4,
76+
q: 4,
77+
S: 4,
78+
s: 4,
79+
T: 4,
80+
t: 2,
81+
V: 1,
82+
v: 1,
83+
Z: 0,
84+
z: 0
8585
};
8686

8787
var ParsedPath = function () {
@@ -131,18 +131,18 @@
131131
if (mode === 'BOD') {
132132
if (token.text === 'M' || token.text === 'm') {
133133
index++;
134-
param_length = PARAMS[token.text].length;
134+
param_length = PARAMS[token.text];
135135
mode = token.text;
136136
} else {
137137
this.parseData('M0,0' + d);
138138
return;
139139
}
140140
} else {
141141
if (isType(token, this.NUMBER)) {
142-
param_length = PARAMS[mode].length;
142+
param_length = PARAMS[mode];
143143
} else {
144144
index++;
145-
param_length = PARAMS[token.text].length;
145+
param_length = PARAMS[token.text];
146146
mode = token.text;
147147
}
148148
}
@@ -156,7 +156,7 @@
156156
return;
157157
}
158158
}
159-
if (PARAMS[mode]) {
159+
if (typeof PARAMS[mode] === 'number') {
160160
var segment = { key: mode, data: params };
161161
this.segments.push(segment);
162162
index += param_length;

dist/rough.umd.es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rough.umd.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
return token.type === type;
99
}
1010
const PARAMS = {
11-
A: { length: 7 },
12-
a: { length: 7 },
13-
C: { length: 6 },
14-
c: { length: 6 },
15-
H: { length: 1 },
16-
h: { length: 1 },
17-
L: { length: 2 },
18-
l: { length: 2 },
19-
M: { length: 2 },
20-
m: { length: 2 },
21-
Q: { length: 4 },
22-
q: { length: 4 },
23-
S: { length: 4 },
24-
s: { length: 4 },
25-
T: { length: 4 },
26-
t: { length: 2 },
27-
V: { length: 1 },
28-
v: { length: 1 },
29-
Z: { length: 0 },
30-
z: { length: 0 }
11+
A: 7,
12+
a: 7,
13+
C: 6,
14+
c: 6,
15+
H: 1,
16+
h: 1,
17+
L: 2,
18+
l: 2,
19+
M: 2,
20+
m: 2,
21+
Q: 4,
22+
q: 4,
23+
S: 4,
24+
s: 4,
25+
T: 4,
26+
t: 2,
27+
V: 1,
28+
v: 1,
29+
Z: 0,
30+
z: 0
3131
};
3232
class ParsedPath {
3333
constructor(d) {
@@ -72,7 +72,7 @@
7272
if (mode === 'BOD') {
7373
if (token.text === 'M' || token.text === 'm') {
7474
index++;
75-
param_length = PARAMS[token.text].length;
75+
param_length = PARAMS[token.text];
7676
mode = token.text;
7777
}
7878
else {
@@ -82,11 +82,11 @@
8282
}
8383
else {
8484
if (isType(token, this.NUMBER)) {
85-
param_length = PARAMS[mode].length;
85+
param_length = PARAMS[mode];
8686
}
8787
else {
8888
index++;
89-
param_length = PARAMS[token.text].length;
89+
param_length = PARAMS[token.text];
9090
mode = token.text;
9191
}
9292
}
@@ -101,7 +101,7 @@
101101
return;
102102
}
103103
}
104-
if (PARAMS[mode]) {
104+
if (typeof PARAMS[mode] === 'number') {
105105
const segment = { key: mode, data: params };
106106
this.segments.push(segment);
107107
index += param_length;

dist/rough.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)