Skip to content

Commit 019ec02

Browse files
committedMay 30, 2020
fix: guard all toVal calls;
+2B, but worth it
1 parent 4fa8811 commit 019ec02

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed
 

‎src/index.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
function toVal(mix) {
22
var k, y, str='';
3-
if (mix) {
4-
if (typeof mix === 'object') {
5-
if (Array.isArray(mix)) {
6-
for (k=0; k < mix.length; k++) {
3+
4+
if (typeof mix === 'object') {
5+
if (Array.isArray(mix)) {
6+
for (k=0; k < mix.length; k++) {
7+
if (mix[k]) {
78
if (y = toVal(mix[k])) {
89
str && (str += ' ');
910
str += y;
1011
}
1112
}
12-
} else {
13-
for (k in mix) {
14-
if (mix[k]) {
15-
str && (str += ' ');
16-
str += k;
17-
}
13+
}
14+
} else {
15+
for (k in mix) {
16+
if (mix[k]) {
17+
str && (str += ' ');
18+
str += k;
1819
}
1920
}
20-
} else if (typeof mix !== 'boolean' && !mix.call) {
21-
str += mix;
2221
}
22+
} else if (typeof mix !== 'boolean' && !mix.call) {
23+
str += mix;
2324
}
25+
2426
return str;
2527
}
2628

0 commit comments

Comments
 (0)
Please sign in to comment.