I left PredicateFn's eventual return type as any as it didn't seem necessary to restrict it to boolean (I could be convinced either way)
I don't think these definitions would work for generator functions, which I'm not familiar enough with. I suspect this could be fixed by changing PotentialPromise to T | Promise<T> | Iterable<PotentialPromise<T>> although this would restrict every yield to type T, when we only care about the very last value being of type T.
It's also highly possible that I misunderstood transducers, as I'm having trouble wrapping my head around the concept.
A couple of notes:
any
as it didn't seem necessary to restrict it toboolean
(I could be convinced either way)PotentialPromise
toT | Promise<T> | Iterable<PotentialPromise<T>>
although this would restrict every yield to typeT
, when we only care about the very last value being of typeT
.It's also highly possible that I misunderstood transducers, as I'm having trouble wrapping my head around the concept.
Let me know what you think, thanks!