Array
Map+filter operation where undefined transformations are filtered out
Given an array and a transform function, returns a new array with each transformed element that does not evaluate to undefined.
import { collect } from 'radash'
const gods = [
{
name: 'Ra',
culture: 'egypt'
},
{
name: 'Zeus',
culture: 'greek'
},
{
name: 'Loki',
culture: 'greek'
}
]
collect(gods, g => (g.culture === 'greek' ? g.name.toUpperCase() : undefined)) // => ['ZEUS', 'LOKI']