iterflow 0.2.2 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3342,19 +3342,16 @@ function asyncIter(source) {
3342
3342
  function fromPromises(promises) {
3343
3343
  return new Asynciterflow({
3344
3344
  async *[Symbol.asyncIterator]() {
3345
- const pending = new Set(promises);
3346
3345
  const results = /* @__PURE__ */ new Map();
3347
3346
  const indexed = promises.map((p, i) => p.then((v) => ({ i, v })));
3348
- while (pending.size > 0) {
3349
- const result = await Promise.race(indexed);
3350
- results.set(result.i, result.v);
3351
- pending.delete(promises[result.i]);
3352
- let nextIndex = promises.length - pending.size - 1;
3353
- while (results.has(nextIndex)) {
3354
- yield results.get(nextIndex);
3355
- results.delete(nextIndex);
3356
- nextIndex++;
3357
- }
3347
+ await Promise.all(
3348
+ indexed.map(async (p) => {
3349
+ const result = await p;
3350
+ results.set(result.i, result.v);
3351
+ })
3352
+ );
3353
+ for (let i = 0; i < promises.length; i++) {
3354
+ yield results.get(i);
3358
3355
  }
3359
3356
  }
3360
3357
  });