feat: 🎸 Add = keyword for equality matching

Support = keyword for equality matching in numeric columns
This commit is contained in:
Faris Ansari 2018-12-10 20:05:19 +05:30
parent 188b61bf1b
commit b6d4a0eea7

View File

@ -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()