From b6d4a0eea79f2e2ac1defbb9a0061610166153bc Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 10 Dec 2018 20:05:19 +0530 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Add=20=3D=20keyword=20fo?= =?UTF-8?q?r=20equality=20matching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support = keyword for equality matching in numeric columns --- src/filterRows.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/filterRows.js b/src/filterRows.js index 18e0f47..0adbdad 100644 --- a/src/filterRows.js +++ b/src/filterRows.js @@ -55,6 +55,15 @@ function getFilterMethod(filter) { .map(cell => cell.rowIndex); }, + equals(keyword, cells) { + return cells + .filter(cell => { + const value = parseFloat(cell.content); + return value === keyword; + }) + .map(cell => cell.rowIndex); + }, + range(rangeValues, cells) { return cells .filter(cell => { @@ -100,6 +109,17 @@ function guessFilter(keyword = '') { }; } + if (keyword.startsWith('=')) { + if (isNumber(keyword.slice(1))) { + return { + type: 'equals', + text: Number(keyword.slice(1).trim()) + }; + } + + keyword = keyword.slice(1); + } + return { type: 'contains', text: keyword.toLowerCase()