Skip to content

Commit

Permalink
Merge c78006a into ce035ee
Browse files Browse the repository at this point in the history
  • Loading branch information
matthemsteger committed Jul 4, 2020
2 parents ce035ee + c78006a commit 29225f7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/parsimmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ function makeLineColumnIndex(input, i) {

// Returns the sorted set union of two arrays of strings
function union(xs, ys) {
// for newer browsers/node we can improve performance by using
// modern JS
if (typeof Set !== "undefined" && Array.from) {
// eslint-disable-next-line no-undef
var set = new Set(xs);
for (var y = 0; y < ys.length; y++) {
set.add(ys[y]);
}
var arr = Array.from(set);
arr.sort();
return arr;
}
var obj = {};
for (var i = 0; i < xs.length; i++) {
obj[xs[i]] = true;
Expand Down

0 comments on commit 29225f7

Please sign in to comment.