How can I memoize a promise-based function?
Would straightforward memoization of the function suffice?
function foo() {
return new Promise((reso
Note that your function has the deferred anti pattern and can be simplified further:
foo.value = null;
function foo(){
if(foo.value) return foo.value;
return (foo.value = doSomethingAsync());
}
That is, memoization is so simple in this case you don't even have to call .memoize. Also your original function suppressed errors.