This question may require a title for editing.
Hi, I have a method that returns an object or promise. The function is as follows:
function getAllTypes()
{
if(cache_hit)
return from_cache;
else
{
findAllTypes.then(function(result){
return result;
}
}
}
This function will either return a promise or a simple JS object, as appropriate. This is a utility function and will be used in many different places. I would like to keep a constant return type, be it a promise or a simple JS object (which does not need permission) in both cases.
Is there any way to do this?
source
share