Why would anyone code like this?
R.compose(
R.ifElse(R.includes(R.isNil), R.always(null), R.identity),
R.map(R.path(['order'])),
)(ordersCreateData)
It's also slower than normal JS, and is so hard to understand.
Here's the JS equivalent
const orders = ordersCreateData.map(item => item.order);
if (orders.includes(null) || orders.includes(undefined)) {
orders = null;
}
Top comments (1)
I can read both equally well because I learned the basics of both. But I agree. Using const instead of let and avoiding assigning to the same variable twice is an important lesson in my opinion though. Disallowing mutation allows you to confidently know the end result of a function better. It also allows for greater machine optimization for concurrent or parallel execution in theory.