Implement `customPromiseAll(promises)` that mimics `Promise.all()`.
It should:
1
Take an array of promises and return a new promise.
2
Resolve when all promises resolve, returning an array of results.
3
Reject immediately if any promise rejects.
javascript
Difficulty: 5/10
Promise combinators, error handling, asynchronous control flow
javascript
Scenario Questions
0-2 years experience
1How would you implement a function customPromiseAll that takes an array of promises and returns a promise that resolves with an array of results in the same order?
2What should customPromiseAll do if one of the input promises rejects?
3If the input array mixes plain values and promises, how does your implementation handle those values?
2-5 years experience
1We have a feature that loads data from three APIs in parallel using customPromiseAll, but it sometimes hangs when an API never resolves. How would you modify your implementation to handle such a case?
2A teammate points out that your customPromiseAll doesn't preserve result order when promises resolve out of order. Explain why that happens and how to fix it.
3You need to collect all errors from every promise before rejecting, instead of rejecting on the first error. How would you change the implementation?
5-8 years experience
1Design an extension to customPromiseAll that adds per‑promise timeout and cancels remaining promises if any fail, suitable for a microservice framework.
2When running thousands of async tasks in parallel with customPromiseAll we hit memory pressure. What strategies would you use to limit concurrency while preserving overall behavior?
3Compare a naive customPromiseAll implementation with using native Promise.all plus polyfills in terms of performance and error semantics for a large codebase.
8+ years experience
1We are migrating legacy callback‑based orchestration to a promise‑based API. How would you design a reusable utility library that includes customPromiseAll, ensuring good API design, TypeScript typings, and backward compatibility across teams?
2If we must support environments without native Promise support, how would you structure the implementation and distribution of customPromiseAll to keep bundle size low and behavior consistent?
3Discuss how you would add observability (tracing, metrics) to customPromiseAll in a distributed system and what impact that has on its design.
Follow-up Questions
How do you guarantee that the results preserve the original order of the input?
What happens if the input array contains non‑Promise values?
How would you test your customPromiseAll implementation?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.