Actual time : the reason .join was to make @spion happy. No wonder using .join means that you have a static and well-known number of promises, which makes it easier to use with TypeScript. Petka (Esailija) liked the idea, as well as the fact that it can be further optimized because it does not need to obey the strange guarantees that another form must adhere to.
Over time, people started (at least I) started using it for other use cases, namely using promises as a proxy.
So, tell us what it does better:
Static analysis
It is difficult to statically analyze Promise.all , since it works with an array with unknown types of promises of potentially different types. Promise.join can be entered, since it can be considered as taking a tuple - for example, for case 3 promises you can give it a signature like (Promise<S>, Promise<U>, Promise<T>, ((S,U,T) -> Promise<K> | K)) -> Promise<K> , which simply cannot be done in a safe way for Promise.all .
proxying
This is very convenient to use when writing promise code in a proxy style:
var user = getUser(); var comments = user.then(getComments); var related = Promise.join(user, comments, getRelated); Promise.join(user, comments, related, (user, comments, related) => { // use all 3 here });
It's faster
Since he does not need to display the value of this promises cache and store all checks .all(...).spread(...) - it will work a little faster.
But ... you, as a rule, do not care.
Benjamin gruenbaum
source share