Skip to content

Commit 89af2cc

Browse files
committed
join_adjacent now takes more than one type
1 parent 66dbec8 commit 89af2cc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

syntax/abstract.mjs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ export function list_into(Type) {
5656
return entries =>
5757
always(new FTL.Resource(
5858
entries
59-
.reduce(join_adjacent(FTL.Junk), [])
60-
.reduce(join_adjacent(FTL.Comment), [])
61-
.reduce(join_adjacent(FTL.GroupComment), [])
62-
.reduce(join_adjacent(FTL.ResourceComment), [])
59+
.reduce(join_adjacent(
60+
FTL.Junk,
61+
FTL.Comment,
62+
FTL.GroupComment,
63+
FTL.ResourceComment), [])
6364
.reduce(attach_comments, [])
6465
.filter(remove_blank_lines)));
6566
case FTL.SelectExpression:
@@ -117,15 +118,16 @@ export function into(Type) {
117118
}
118119
}
119120

120-
function join_adjacent(Type) {
121+
function join_adjacent(...types) {
121122
return function(acc, cur) {
122123
let prev = acc[acc.length - 1];
123-
if (prev instanceof Type && cur instanceof Type) {
124-
join_of_type(Type, prev, cur);
125-
return acc;
126-
} else {
127-
return acc.concat(cur);
124+
for (let Type of types) {
125+
if (prev instanceof Type && cur instanceof Type) {
126+
join_of_type(Type, prev, cur);
127+
return acc;
128+
}
128129
}
130+
return acc.concat(cur);
129131
};
130132
}
131133

0 commit comments

Comments
 (0)