Skip to content

Commit

Permalink
fix(percentageFilter): deal with empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
maasencioh committed Jul 20, 2017
1 parent 854e835 commit 212fd23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/filter/percentageFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export function percentageFilter(chromatogram, serieName, options = {}) {
}

function applyFilter(serie, percentage) {
var basePeak = arrayMax(serie[1]);
var basePeak;
try {
basePeak = arrayMax(serie[1]);
} catch (e) {
basePeak = 0;
}
var filtered = [[], []];
for (var i = 0; i < serie[0].length; i++) {
if (serie[1][i] > percentage * basePeak) {
Expand Down

0 comments on commit 212fd23

Please sign in to comment.