Created
September 19, 2017 10:53
-
-
Save gabrielhpugliese/57004cfbc99ccf2cd17ef4a79c272231 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
import { | |
compose, | |
findIndex, | |
pullAt, | |
curry, | |
} from 'lodash/fp'; | |
const MY_LIST = [/* items here */]; | |
const removeFromList = curry((itemToRemove, list) => compose( | |
(index) => pullAt(index, list), | |
findIndex((item) => item === itemToRemove), | |
)(list)); | |
const removeItemA = removeFromList('itemA'); | |
const removeItemB = removeFromList('itemB'); | |
const myListWithoutA = removeItemA(MY_LIST); | |
const myListWithoutB = removeItemB(MY_LIST); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment