Memoizing async functions in Javascript