I am trying move more towards functional programming in my javascript applications. I currently use the library ramda as a base lib for this.
My desire:
- Create a function removeUserFromList(username, list) which returns the items in the list that does not match the username.
- Make the implementation as short as possible, relying on existing functions in the Ramda library as much as possible.
Conditions:
A list containing nested user objects:
[{
providers: {
github: {
login: "username1"
}
}
},
{
providers: {
github: {
login: "username2"
}
}
}]
Acheived so far:
var list = [{providers: {github: {login: "username1"}}},
{providers: {github: {login: "username2"}}}];
var getLoginName = R.useWith(R.path('providers.github.login'));
var isLoginNameEq = R.useWith(R.eq, getLoginName);
isLoginNameEq(list[0], "username1") // => true
//From this point on I am totally clueless,
//but I believe I should combine these functions
//with R.reject in some way.
Plunkr demo:
http://plnkr.co/edit/1b5FjxV3Tcgz7kozW1jX
Question:
Is there any better suited function to achieve something similar to R.eq but on nested objects (perhaps R.pathEq)?