Closed dead-claudia closed 5 years ago
while generators themselves probably wouldn't be specified here, a lot of iterator libs have tee support, which might be interesting here.
Yeah, but as noted in the "Potential FAQs" section, tee
isn't in of itself sufficient. My .fork()
is similar to a .tee()
, but the key difference is that the side effects are replayed with results not buffered, where .tee()
utilities only attempt them once and always buffer their results.
closing as out of scope
I trying to mimc ReadableStream.prototype.tee
but with just plain asyncIterator instead and then i found this: https://stackoverflow.com/a/46416353/1008999
reason being is that i want to be able to handle both whatwg & node streams the same way.
I've got a related proposal that suggests forkable generators. I do specifically avoid having it generalized, because the behavior could be anywhere from unexpected to just plain wrong, and generator callees are not always written to potentially support cloning and replaying continuations with different
next
parameters.The "Potential FAQs" section was written in part as a response to initial #tc39 IRC feedback, and I'm filing this issue based on a recommendation there.