Javascript AMD promises and async processing