Skip to content

Instantly share code, notes, and snippets.

@pramendra
Created June 19, 2020 13:19
Show Gist options
  • Save pramendra/347c302ea317af84107a561dc7d92330 to your computer and use it in GitHub Desktop.
Save pramendra/347c302ea317af84107a561dc7d92330 to your computer and use it in GitHub Desktop.
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