Created
September 19, 2017 10:45
-
-
Save gabrielhpugliese/d9f12294d7eb14e57d0cd6e39a643462 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, | |
cond, | |
} from 'lodash/fp'; | |
const MY_LIST = [/* items here */]; | |
const findMyItemIndex = findIndex(item => item === 'MY_ITEM'); | |
const changeItemToSomething = () => // returns NEW object (immutable) | |
const doMagic = (item, list) => { | |
const index = findMyItemIndex(item); | |
return index > -1 | |
&& changeItemToSomething(item, list) | |
|| list; | |
}; | |
doMagic({a: 1}, MY_LIST); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment