CSS Example: Move null filtering from extractList to buildList

This makes extractList identical to the same function in other grammars
and makes it so that nulls are dealt with in only one function (until
now, they were dealt with both in extractList and buildList).

The refactoring should be safe as extractList isn't by itself used in
contexts where it can be passed a list containing nulls.
redux
David Majda 8 years ago
parent 647d488147
commit ff3cc7930e

@ -23,13 +23,12 @@
}
function extractList(list, index) {
return list
.map(function(element) { return element[index]; })
.filter(function(element) { return element !== null; });
return list.map(function(element) { return element[index]; });
}
function buildList(head, tail, index) {
return (head !== null ? [head] : []).concat(extractList(tail, index));
return [head].concat(extractList(tail, index))
.filter(function(element) { return element !== null; });
}
function buildExpression(head, tail) {

Loading…
Cancel
Save