I accepted @Blindman67's answer despite I'd already mentioned in my question that using Promise.race() promises.length many times is hurting me. However he has a strong point on the usage of Arrays. I had to find a better data structure and i think this happens to be a Queue, preferably an Async Queue. An Async Queue, in my terms, is a type that do not have ...
You have an iterator
Your code implements an iterator, you are right. You have defined a __next__ method and it works well.
I would tweak your code slightly, though:
remove the check because iterators can be empty and that is okay;
fix minor spacing issues around operators, etc;
use augmented assignment to increment;
change order of statements in __next__ ...
You are issuing promises without a guarantee of being able to handle all or some of the resolving promises.
This will happen if promises resolve before you start the for await loop.
The offending code is in the line this.forEach(p => p.then(v => this.#resolve(v), e => this.#reject(e)));
The calls to this.#resolve and this.#...
I would suggest you use something like System.Threading.Tasks.Dataflow or System.Reactive from NuGet.
Dataflow in particular is made to feed data through a pipeline.
Consider passing the CancellationToken to the delegate.
Always validate arguments
Smaller more specializes methods can make the code easier to understand.
public static Task<...