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/README.md CHANGED
@@ -223,6 +223,9 @@ const movingAverages = iter(temperatures)
223
223
  .toArray();
224
224
  ```
225
225
 
226
+ <!-- BENCHMARK_SUMMARY_START -->
227
+ <!-- BENCHMARK_SUMMARY_END -->
228
+
226
229
  ## License
227
230
 
228
231
  The Unlicense - See [LICENSE](LICENSE) for details.
package/dist/index.cjs CHANGED
@@ -3344,19 +3344,16 @@ function asyncIter(source) {
3344
3344
  function fromPromises(promises) {
3345
3345
  return new Asynciterflow({
3346
3346
  async *[Symbol.asyncIterator]() {
3347
- const pending = new Set(promises);
3348
3347
  const results = /* @__PURE__ */ new Map();
3349
3348
  const indexed = promises.map((p, i) => p.then((v) => ({ i, v })));
3350
- while (pending.size > 0) {
3351
- const result = await Promise.race(indexed);
3352
- results.set(result.i, result.v);
3353
- pending.delete(promises[result.i]);
3354
- let nextIndex = promises.length - pending.size - 1;
3355
- while (results.has(nextIndex)) {
3356
- yield results.get(nextIndex);
3357
- results.delete(nextIndex);
3358
- nextIndex++;
3359
- }
3349
+ await Promise.all(
3350
+ indexed.map(async (p) => {
3351
+ const result = await p;
3352
+ results.set(result.i, result.v);
3353
+ })
3354
+ );
3355
+ for (let i = 0; i < promises.length; i++) {
3356
+ yield results.get(i);
3360
3357
  }
3361
3358
  }
3362
3359
  });