Created
November 11, 2015 16:34
-
-
Save ReDetection/fccb9bf4383ae90e850d to your computer and use it in GitHub Desktop.
filterHotelsByRatePlan.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from 'ramda'; | |
// [] -> Boolean | |
function notEmpty(xs) { | |
return xs.length > 0; | |
} | |
// (RatePlan -> Boolean) -> [AvailableHotel] -> [AvailableHotel] | |
function filterHotelsByRatePlan(ratePlanIndicator) { | |
const ratePlans = R.filter(ratePlanIndicator); | |
const roomType = R.evolve({ratePlans}); | |
const roomTypes = R.compose( | |
R.filter(R.compose(notEmpty, R.prop('ratePlans'))), | |
R.map(roomType) | |
); | |
const availableHotel = R.evolve({roomTypes}); | |
return R.compose( | |
R.filter(R.compose(notEmpty, R.prop('roomTypes'))), | |
R.map(availableHotel) | |
); | |
} | |
export default filterHotelsByRatePlan; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment