Skip to content

Commit

Permalink
Merge pull request #311 from matchID-project/fix/compatibility-firefo…
Browse files Browse the repository at this point in the history
…x-link-check

🚸 Replace flat function to maintain support for firefox 52
  • Loading branch information
rhanka committed Oct 9, 2020
2 parents 262dec2 + 9e9a1af commit 3b450f5
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/views/LinkCheck.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,34 @@
});
return r
})
.flat()
.map(row => flatten(row, 1))
.filter(row => !filter || row[header.indexOf('score')])
.map(row => header.map((col, i) => protectField(row[i])).join($linkCsvType.sep) + '\r\n')];
}
const flatten = (array, depth) => {
// If no depth is specified, default to 1
if (depth === undefined) {
depth = 1;
}
// Recursively reduce sub-arrays to the specified depth
const flat = (arr, depth) => {
// If depth is 0, return the array as-is
if (depth < 1) {
return arr.slice();
}
// Otherwise, concatenate into the parent array
return arr.reduce(function (acc, val) {
return acc.concat(Array.isArray(val) ? flat(val, depth - 1) : val);
}, []);
};
return flat(array, depth);
};
</script>

<style>
Expand All @@ -177,4 +200,4 @@
height: 14rem;
additive-symbols: 14rem;
}
</style>
</style>

0 comments on commit 3b450f5

Please sign in to comment.