4aab34dd by Gary Katsevman

switch to forEach to reduce for main return

1 parent 7865c573
1 /***** Start *****/ 1 /***** Start *****/
2 start 2 start
3 = tags:lines+ .* { 3 = tags:lines+ .* {
4 var obj = {}, 4 var choices = {
5 choices = {
6 segments: 1, 5 segments: 1,
7 comments: 1, 6 comments: 1,
8 playlists: 1 7 playlists: 1
9 }; 8 };
10 tags.forEach(function(tag) { 9 return tags.reduce(function(obj, tag) {
11 for (var p in tag) { 10 for (var p in tag) {
12 if (p in choices) { 11 if (p in choices) {
13 if (Object.prototype.toString.call(obj[p]) === '[object Array]') { 12 if (Object.prototype.toString.call(obj[p]) === '[object Array]') {
...@@ -18,10 +17,11 @@ start ...@@ -18,10 +17,11 @@ start
18 } else { 17 } else {
19 obj[p] = tag[p]; 18 obj[p] = tag[p];
20 } 19 }
21 } 20
22 });
23 return obj; 21 return obj;
24 } 22 }
23 }, {});
24 }
25 25
26 lines 26 lines
27 = comment:comment _ { var obj = {}; obj["comments"] = comment; return obj; } 27 = comment:comment _ { var obj = {}; obj["comments"] = comment; return obj; }
......