Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Created September 19, 2017 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielhpugliese/57004cfbc99ccf2cd17ef4a79c272231 to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/57004cfbc99ccf2cd17ef4a79c272231 to your computer and use it in GitHub Desktop.
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