[email protected] - 2020-09-02
- Fixed memory leaks in static combinator functions race, merge, zip and latest due to Promise.race.
[email protected] - 2020-08-03
- Fixed missing file in package.json.
[email protected] - 2020-08-03
- Fixed throw method not catching promises in newer versions of v8 (node.js 12+).
- Added ESM support for newer versions of node.
[email protected] - 2019-10-13
- build files with target set to es5 rather than esnext
[email protected] 2019-11-10
- build files with target set to es5 rather than esnext
[email protected] 2019-11-10
- build files with target set to es5 rather than esnext
[email protected] 2019-11-10
- build files with target set to es5 rather than esnext
[email protected] - 2019-10-13
- upgrade dependencies
[email protected] - 2019-10-13
- upgrade dependencies
[email protected] - 2019-10-13
- upgrade dependencies
[email protected] 2019-11-10
This release overhauls the push
and stop
promises and the return
and throw
methods to be more in line with the behavior of async generators. If you used repeaters to simply add and remove event handlers, you can upgrade without worrying about breaking changes. However, if you awaited push
calls, read the value of the stop
promise, or used the return
or throw
methods in non-trivial ways, this release may break your code.
-
Previously, the n-th call to
push
resolved to the value passed to the n-th call toRepeater.prototype.next
. This was inaccurate insofar as async generators resume the n-thyield
with the value passed to the n+1-th call tonext
. Additionally, async generators completely ignore the first value passed tonext
entirely. The former behavior of repeaters was confusing insofar as the first call topush
would always resolve immediately, becausepush
could not be called untilnext
was called for the first time. In 3.0, the behavior has now been changed so that the n-th call topush
resolves to the n+1-th call tonext
.For the most part, code which awaits
push
will work as expected, except when the code relied on the first call topush
resolving immediately. To make sure you’re not relying on the old behavior ofpush
, you should make sure that you await push at the bottom of loops, rather than the top. See the changes totimers
as an example. -
Calling
Repeater.prototype.throw
will now cause the previouspush
call to reject, rather than simply stopping the repeater and throwing the error. This means errors thrown into repeaters are now recoverable. If you call push without awaiting or callingthen/catch
on the returned promise and then call thethrow
method, the repeater will rethrow the error, preserving the previous behavior. However, if you awaitpush
or otherwise call thethen
orcatch
methods, it becomes your responsibility to handle errors thrown in viathrow
and stop the repeater. #43 -
The
stop
promise no longer resolves to the value passed toRepeater.prototype.return
. Instead, it consistently fulfills toundefined
when the repeater is stopped. Additionally, callingRepeater.prototype.return
will return a result whose value is always whatever was passed toreturn
. In the case of premature returns, the return value of the executor is ignored unless it throws an error. #41This change was made because there is no way with async generators to inspect the value passed to return from within the async generator. Additionally, the only way to modify the result returned from the
return
method would be to put areturn
statement in afinally
block within the async generator, which is typically considered to be a bad practice. Repeaters now uniformly return the value passed to thereturn
method. See #40 for a longer explanation for why we made this change. -
Errors thrown by the executor now take priority over rejections passed to push. If a pushed promise rejects, the repeater will await the execution result and throw an error thrown by the executor instead of the rejected promise.
-
Changes to combinator methods
- Improved type inference for
Repeater.race
andRepeater.merge
Repeater.merge
yields non-iterable values, so you can call merge on an iterable of promises to get an async iterator which produces values as each promise fulfills.- Iterables passed to combinator methods are upgraded to async iterators, so that promise-like values are awaited and unwrapped before being pushed to the repeater
- Improved type inference for
-
Changes to typescript typings:
Repeater
,RepeaterExecutor
,Push
and other related types now take the type parametersTReturn
andTNext
in line with typescript 3.6’s strict async generator typings.- The
RepeaterBuffer
interface and concrete classes no longer accept a type parameter. All places where the type parameter would have been used,unknown
is used instead. You should never directly add or remove values from buffers. - The typings of the
next
andreturn
methods have been changed to acceptPromiseLike<T>
andPromiseLike<TReturn>
respectively as parameters.
[email protected] - 2019-10-13
- Fixed build error in @repeaterjs/pubsub
[email protected] - 2019-06-29
- Fixed timers using the wrong version of @repeaterjs/repeater
[email protected] - 2019-06-29
- Fixed limiters using the wrong version of @repeaterjs/repeater
[email protected] - 2019-06-29
- Fixed pubsub using the wrong version of @repeaterjs/repeater.
[email protected] - 2019-08-24
- Renamed all instances of
Channel
toRepeater
(e.g.Channel
toRepeater
,ChannelBuffer
toRepeaterBuffer
). See #18 for the rationale behind this name change.
[email protected] - 2019-08-24
- Renamed all instances of
Channel
toRepeater
(e.g.Channel
toRepeater
,ChannelBuffer
toRepeaterBuffer
). See #18 for the rationale behind this name change.
[email protected] - 2019-08-24
- Renamed all instances of
Channel
toRepeater
(e.g.Channel
toRepeater
,ChannelBuffer
toRepeaterBuffer
). See #18 for the rationale behind this name change.
[email protected] - 2019-08-24
- Renamed all instances of
Channel
toRepeater
(e.g.Channel
toRepeater
,ChannelBuffer
toRepeaterBuffer
). See #18 for the rationale behind this name change.
[email protected] - 2019-06-09
- Fixed timers using the wrong version of @channel/channel.
[email protected] - 2019-06-09
- Fixed limiters using the wrong version of @channel/channel.
[email protected] - 2019-06-09
- Fixed pubsub using the wrong version of @channel/channel.
[email protected] - 2019-06-09
- The
Channel
class now exposes the static methodsChannel.race
,Channel.merge
,Channel.zip
andChannel.latest
#4.
- The
close
andstop
arguments passed to executor have been merged as the second argument. - The
stop
promise resolves to argument passed toreturn
ifreturn
is called. - The
push
function now resolves to the value passed to next. - The
push
function now unwraps promise-like values passed to push. - Buffers now throw an error if
remove
is called when the buffer is empty. - Channel properties and methods which don’t belong to the async iterator interface are now hidden using a private WeakMap.
- Channels stop immediately when the executor throws an error.
- Executor now runs synchronously when
next
is called for the first time (#10). - The final iteration result/errors are now consumed by iterator methods.
return
/throw
behave more like the methods do forasync generators
.
[email protected] - 2019-06-09
delay
now returns an channel which can be reusedtimeout
returns a channel
[email protected] - 2019-06-09
- throttler can now be passed a
cooldown
boolean option which forces the channel to wait before yielding the final token.
- semaphore and throttler now both return channels rather than async iterators.
- throttler function now takes options instead of a number representing limit as the second arg.
- semaphore and throttler will throw a RangeError if limit is less than 1.
- throttler now uses a sliding window to limit #1.
[email protected] - 2019-06-09
- Type definitions have changed slightly.
[email protected] - 2019-05-06
- Adds throw method to channels.
[email protected] - 2019-04-08
[email protected] - 2019-04-08
[email protected] - 2019-04-08
[email protected] - 2019-04-08
- Initial release.
[email protected] - 2019-04-08
- Initial release.
[email protected] - 2019-04-08
- Initial release.
[email protected] - 2019-04-08
- Initial release.