Closed valgeirb closed 5 years ago
Hi @valgeirb,
Would this work?
const objList = [
{name: 'Janice', color: 'Green', active: false},
{name: 'Fred', color: 'Orange', active: true},
{name: 'George', color: 'Blue', active: true},
{name: 'Jen', color: 'Red', active: false},
]
objList.filter(o => o.active)
:)
Then you can pass the result of that to match-sorter to match on the other properties:
const objList = [
{name: 'Janice', color: 'Green', active: false},
{name: 'Fred', color: 'Orange', active: true},
{name: 'George', color: 'Blue', active: true},
{name: 'Jen', color: 'Red', active: false},
]
matchSorter(objList.filter(o => o.active), 'jn', {keys: ['name', 'color']})
// [{name: 'Janice', color: 'Green', active: false}, {name: 'Jen', color: 'Red', active: false}]
I hope that helps!
I'm trying to filter based on an active state.
If I try to filter by false it returns the whole list.
It works correctly if I filter by true.
Should I not be able to filter by using a false value? Thanks for the great package.