The JavaScript result of your example looks like this:
(again, beautified because DesignToJS crams everything in one line to preserve the line numbers of your actual code):
function loadAndPrintFile(contents) {
if (!contents) {
fs.readFile(function(error, contents){
if(error !== null && error !== undefined){
return error;
}
});
}
console.log(contents);
}
If you omit the function body, it will only expand to the end of the current logical 'context' (or whatever it's called)
I'd suggest writing it like this in DesignToJS:
loadAndPrintFile: (contents! console.log) {
fs.readFile() -> (error!, contents! console.log)
}
Result looks like this:
function loadAndPrintFile(contents) {
if(contents !== null && contents !== undefined){
return console.log(contents);
}
fs.readFile(function(error, contents){
if(error !== null && error !== undefined){
return error;
}
if(contents !== null && contents !== undefined){
return console.log(contents);
}
});
}
Edit: I just submitted a patch that avoids unnecessary binding of 'this' if 'this' is not actually used.