Last active
November 18, 2021 19:26
-
-
Save moeinrahimi/20b8145dfbadcacff18164a432c4ce7b to your computer and use it in GitHub Desktop.
pure function
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
const R = require('ramda'); | |
const filterFood = (food) => R.gt(food.amount, 0); | |
const cleaner = (day) => | |
R.map((item) => R.filter(filterFood, item.foods), day.meals); | |
const removeZeroAmounts = (diet) => { | |
const dietClone = R.clone(diet); | |
const cleanDays = R.map(cleaner, dietClone.days); | |
return { ...dietClone, days: cleanDays }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can make this more readable, you don't need ramda