I've been staring at this code for so long trying to understand what it's doing, but have no idea what's going on.
export const fieldDisabledIs = expectedValue => ({fieldDisabled}) =>
(expectedValue === false && isEmpty(fieldDisabled)) || fieldDisabled === expectedValue;
The caller makes a call like this:
fieldDisabledIs(true)
What is it doing? I think since there are two arrow functions, the return is a function itself. Something like:
function(expectedValue)
{
return function ({fieldDisabled})
{
(expectedValue === false && isEmpty(fieldDisabled)) || fieldDisabled === expectedValue;
}
}
Also this line here...
(expectedValue === false && isEmpty(fieldDisabled)) || fieldDisabled === expectedValue;
It seems redundant to have the first check if we can just compare fieldDisabled === expectedValue. Isn't it covered in the second condition?