I recently read a chapter of David Herman's Effective JavaScript[1] that talked about preserving the async contract even if you cache results (ie. can return without an async call from the caller). Try:
if (connectionInstance) {
setTimeout(function(){callback(connectionInstance)}, 0);
return;
}
That way your async functions will always behave the same way.
It looks like a great idea and website. Me and two friends are going to graduate soon from a BS in Computer Engineering and we love to hear more details (expenses!). We are seriously considering a startup but we lack a good idea. We have some knowledge in: Ruby, Ruby on Rails, DB (SQLite, MySQL), Linux, Apache, Javascript, HTML and CSS (including using Bootstrap). Please contact me here: http://goo.gl/kgLWc so we can share details if you're interested. Thanks.
That way your async functions will always behave the same way.
[1] http://effectivejs.com/