On Fri, Oct 11, 2019 at 9:53 PM Jacob Bloom <mr.jacob.bl...@gmail.com> wrote: > What about special handling for Maps? Maybe something like > > ``` > const requests = new Map(); > requests.set('reqA', fetch('...')); > requests.set('reqB', fetch('...')); > const responses = await Promise.all(requests); > console.log( > responses.get('reqA'), > responses.get('reqB'), > ); > ``` > > ...which would continue to fail for most objects and would encourage > using Map over POJOs for map-like data structures. (Since Maps are > iterable, this may break some existing code but I doubt it)
Hm. Since the functor instance over Maps is just the values, and Promise.all is just a special-cased traverse, I think this makes sense to me: Map<keyType, Promise<valueType>> => Promise<Map<keyType, valueType>> I'm fine with this living in another method name, tho. ~TJ _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss