Is there a way to synthetize a "nil or empty" testing like this one ?
if (!shoppingCartLine ||
!shoppingCartLine.relationships ||
!shoppingCartLine.relationships.offer ||
!shoppingCartLine.relationships.offer.links ||
!shoppingCartLine.relationships.offer.links.self)
return null;
to an helper like this :
if (isNilOrEmpty(shoppingCartLine.relationships.offer.links.self))
return null;
or maybe like C#6.0 Null-Conditional Operator :
if (!shoppingCartLine?.relationships?.offer?.links?.self)
return null;
without throwing an error :
Cannot read property 'links' of undefined