aantron / promise

Light and type-safe binding to JS promises
MIT License
340 stars 24 forks source link

Add `Promise.both` #55

Closed anmonteiro closed 4 years ago

anmonteiro commented 4 years ago

This is useful for the and* binding operator.

Currently I'm using:

  let both = (x, y) => {
    Promise.all([x, y])
    ->Promise.map(
        fun
        | [x, y] => (x, y)
        | _ => assert(false),
      );
  };
aantron commented 4 years ago

@anmonteiro Promise.all2 should be suitable for this. It was added for #36 and I called it all2 because I didn't think there was a neat set of special names that also covered all3, all4, etc. :) It's mentioned at the end of Concurrent combinations.

anmonteiro commented 4 years ago

Heh, indeed. Missed it, thanks!