Promise/Future-based asynchrony in javascript