Created
June 19, 2020 13:19
-
-
Save pramendra/347c302ea317af84107a561dc7d92330 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 premLeague = R.equals("Prem League"); | |
const premLeagueInArray = R.any(premLeague); | |
const categories = R.path(["categories"]); | |
const isPremLeagueInArray = R.pipe(categories, premLeagueInArray); | |
const teams = [ | |
{ name: "Liverpool", id: "1", categories: ["Prem League"] }, | |
{ name: "Man Utd", id: "2", categories: ["Blue Square"] }, | |
{ name: "Sheff Utd", id: "2", categories: ["Prem League"] }, | |
]; | |
const premLeagueTeam = [ | |
{ name: "Liverpool", id: "1", categories: ["Prem League"] }, | |
{ name: "Sheff Utd", id: "2", categories: ["Prem League"] }, | |
]; | |
const transducer = R.compose(R.filter(isPremLeagueInArray)); | |
const getPremLeagueTeam = R.transduce(transducer, R.flip(R.append), []); | |
R.equals(getPremLeagueTeam(teams), premLeagueTeam); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment