From 212fd23aa054645eb6c15aaf1ce9cebd5619b8cd Mon Sep 17 00:00:00 2001 From: Miguel Angel Asencio Hurtado Date: Thu, 20 Jul 2017 15:11:25 +0200 Subject: [PATCH] fix(percentageFilter): deal with empty arrays --- src/filter/percentageFilter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/filter/percentageFilter.js b/src/filter/percentageFilter.js index ef85d2d..ffba3fe 100644 --- a/src/filter/percentageFilter.js +++ b/src/filter/percentageFilter.js @@ -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) {