Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
filterHotelsByRatePlan.js
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