Perform map and filter operations in the same iteration
npm install map-siftimportmapSiftfrom'map-sift'typePerson={name: string,height?: number}constpeople: Person[]=[{name: 'Alice',height: 180},{name: 'Bob',height: 168},{name: 'David',height: undefined},{name: 'Emma',height: 160},{name: 'Frank'},{name: 'Grace',height: 155},]// Without mapSift:constheightsMapFilter=people.map(person=>person.height).filter(Boolean)console.log(heightsMapFilter)// [180, 168, 160, 155]// With mapSift:constheightsMapSift=people.flatMap(mapSift(person=>person.height))console.log(heightsMapSift)// [180, 168, 160, 155]