For this example the following would be better if you weren't sure if some fields would be available
constdata=[{wrongName:'Jason',level:7,cool:true},{wrongName:'Blanche',level:8,cool:false}]Maybe(data).map(people=>people.filter(person=>person.cool)).chain(head).chain(get(['name'])).map(name=>name.toUpperCase()).cata({Just:data=>console.log(data),// JASONNothing:()=>console.log('No data available')})
This isn't exactly the same because Ramdas prop() does not return a Maybe, so if that prop did not exist then ramda would return an undefined, which will cause problems down the line. Same with head()
For this example the following would be better if you weren't sure if some fields would be available
It seems to looks better with Ramda, isn't it:
PS: thanks a lot for the article
This isn't exactly the same because Ramdas
prop()
does not return a Maybe, so if that prop did not exist then ramda would return an undefined, which will cause problems down the line. Same withhead()
You are totally right. Sorry for my mistake.