Skip to content

Instantly share code, notes, and snippets.

@ReDetection
Created November 11, 2015 16:34
Show Gist options
  • Save ReDetection/fccb9bf4383ae90e850d to your computer and use it in GitHub Desktop.
Save ReDetection/fccb9bf4383ae90e850d to your computer and use it in GitHub Desktop.
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