Message from JavaScript discussions

July 2017

— 

if (cachedDoc !== null) {
return insertionThunk(cachedDoc);
}
if (conf.isFile) {
return getTemplateXHR(templLoc, conf).then(saveInsertionThunk);
}
return saveInsertionThunk(getTemplateDOM(templLoc));

Message permanent page

— 

saveInsertionThunk is a function which calls conf.cache.saveDoc(templLoc, templDoc); before calling insertionThunk

— Equivalent

— Yes

— Why the else's?

— Habit I suppose, heh

— Bad habit

— :S

— Good catch

— Reduces levels of indentation

— This should be:

if (x) {
return y;
}
// rest of logic

— Looks pretty good now