How to filter items by type?
const items = {
'someHash0': {
type: 'foo',
name: 'a'
},
'someHash1': {
type: 'foo',
name: 'b'
},
'someHash2': {
type: 'foo',
name: 'c'
},
'someHash3': {
type: 'baz',
name: 'd'
},
};
I want to filter by type=foo and get that result:
const items = {
'someHash0': {
type: 'foo',
name: 'a'
},
'someHash1': {
type: 'foo',
name: 'b'
},
'someHash2': {
type: 'foo',
name: 'c'
}
};
I tryied with
return _.mapValues(pairs, function (item) {
return (item.type === 'foo') ?? item
})
but it returns true/false instead of the whole object