Last active
May 8, 2019 13:56
-
-
Save davidlygagnon/bbf980f20454feba8b747628a823bfa5 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
// CoffeeScript | |
getPartNumber = (car) -> | |
car?.getMake()?.model?.partNumber | |
return | |
// JavaScript | |
const getPartNumber = function(car) { | |
__guard__(__guard__(car != null ? car.getMake() : undefined, x1 => x1.model), x => x.partNumber); | |
}; | |
function __guard__(value, transform) { | |
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment