A second attempt at resolving #35. I finally managed to get unhandled pushes to throw when repeater.throw is called by chaining promises in push rather than next/return/throw. The push function is the only place where we have access to both the promise passed to push and the promise returned from push in sequence.
One consequence of this refactoring is that we always pass promises to the push queue and buffer rather than naked values. Therefore, this PR also removes the type parameter of RepeaterBuffer and makes the parameter type of buffer.add and the return type of buffer.remove both unknown. This is beneficial in that it prevents inferring the type of the repeater from the type of its buffer, and makes it slightly harder for typescript users to add or remove values from repeater buffers. Adding or removing values from the repeater’s buffer is not and should not be supported and adding this unknown hitch is the best way to do this that doesn’t involve drastic checks to make sure only repeaters call buffer.add and buffer.remove.
This PR also does a big, dirty clean-up of the test suite.
A second attempt at resolving #35. I finally managed to get unhandled pushes to throw when
repeater.throw
is called by chaining promises inpush
rather thannext
/return
/throw
. Thepush
function is the only place where we have access to both the promise passed topush
and the promise returned frompush
in sequence.One consequence of this refactoring is that we always pass promises to the push queue and buffer rather than naked values. Therefore, this PR also removes the type parameter of RepeaterBuffer and makes the parameter type of
buffer.add
and the return type ofbuffer.remove
bothunknown
. This is beneficial in that it prevents inferring the type of the repeater from the type of its buffer, and makes it slightly harder for typescript users to add or remove values from repeater buffers. Adding or removing values from the repeater’s buffer is not and should not be supported and adding thisunknown
hitch is the best way to do this that doesn’t involve drastic checks to make sure only repeaters callbuffer.add
andbuffer.remove
.This PR also does a big, dirty clean-up of the test suite.