+5
.changeset/violet-suits-yawn.md
+5
.changeset/violet-suits-yawn.md
+3
.editorconfig
+3
.editorconfig
+1
package.json
+1
package.json
+33
pnpm-lock.yaml
+33
pnpm-lock.yaml
············resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==}···resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}···resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
·········+resolution: {integrity: sha512-OGiIzzoBLgWWR0UdRJX98oYO+XKGf7tiK4Zk6tQ/E4IJqGCe7dvkTvgDZV5cFJUzLGDOjeAXrnZoA6QkVySuxw==}+resolution: {integrity: sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==}···+resolution: {integrity: sha512-xRmVi7Zx44lOBuYqG8vzTXuL6IdGOeF9nHX17bjJ8+VE6fsxpdGem0/SBTmAwgYMKYB1WBkqRJVQ+n8GK041pA==}resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==}···resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}+resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==}···resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}+resolution: {integrity: sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==}
+2
-1
scripts/eslint-preset.js
+2
-1
scripts/eslint-preset.js
······
······
+3
-1
scripts/flow-typings-plugin.mjs
+3
-1
scripts/flow-typings-plugin.mjs
···
+20
src/callbag.ts
+20
src/callbag.ts
······
······
+64
-9
src/combine.ts
+64
-9
src/combine.ts
······
···+/** Combines the latest values of several sources into a Source issuing either tuple or dictionary+* `zip` combines several {@link Source | Sources}. The resulting Source will issue its first value+* once all input Sources have at least issued one value, and will subsequently issue a new value+* Depending on whether an array or dictionary object of Sources is passed to `zip`, its emitted+function zip<T>(sources: Source<T>[] | Record<string, Source<T>>): Source<T[] | Record<string, T>> {···+* `combine` takes one or more {@link Source | Sources} as arguments. Once all input Sources have at+* least issued one value it will issue an array of all of the Sources' values. Subsequently, it
+21
src/helpers.ts
+21
src/helpers.ts
···
···+* This is frequently used in the codebase as a no-op initializer value for talkback functions in+* them. Since the {@link Start | Start signal} is assumed to come first and carry a talkback, we can
+12
src/index.ts
+12
src/index.ts
···+* streams, which are sources emitting multiple values, which allow you to create, transform, and
+121
-2
src/observable.ts
+121
-2
src/observable.ts
······
···+* whether it's active, and {@link ObservableSubscription.unsubscribe} may be used to cancel the+* @see {@link https://github.com/tc39/proposal-observable} for the ES Observable specification.+* When `true`, the subscription will not issue new values to the {@link ObservableObserver} and+* The Observer in ES Observables is supplied to {@link Observable.subscribe} to receive events from+* interoperability for push-based streams. When converting from an Observable to a {@link Source},+* @see {@link https://github.com/tc39/proposal-observable} for the ES Observable specification.+* @see {@link ObservableObserver} for the callbacks in an object that are called as Observables+/** An ES Observable type that is a de-facto standard for push-based data sources across the JS+* functionality to Observables, it provides utilities to cleanly convert to and from Observables.+* @see {@link https://github.com/tc39/proposal-observable} for the ES Observable specification.+* @see {@link ObservableObserver} for the callbacks in an object that are called as Observables+* This symbol is used to mark an object as a default ES Observable. By the specification, an object+* that abides by the default Observable implementation must carry a method set to this well-known+* This converts an ES Observable to a {@link Source}. When this Source receives a {@link Sink} and+* the subscription starts, internally, it'll subscribe to the passed Observable, passing through+* all of the Observable's values. As such, this utility provides intercompatibility converting from···+* This converts a {@link Source} to an {@link Observable}. When this Observable is subscribed to, it+* internally subscribes to the Wonka Source and pulls new values. As such, this utility provides
+599
src/operators.ts
+599
src/operators.ts
······························export function scan<In, Out>(reducer: (acc: Out, value: In) => Out, seed: Out): Operator<In, Out> {····································
···+* This can be used to group values over time. A buffer will only be emitted when it contains any···+* This can be used to issue multiple values per emission of an input {@link Source}, while keeping···+/** Flattens a Source emitting Sources into a single Source emitting the inner values in order.+* `concat` accepts an array of {@link Source | Sources} and will emit values from them, starting······+* The output {@link Source} will emit values from all {@link Source | Sources} the mapping function+* This can be used to issue multiple values per emission of an input {@link Source}, essentially···+* `mergeAll` accepts a {@link Source} which must emit {@link Source | Sources}. It will subscribe+* `merge` accepts an array of {@link Source | Sources} and will subscribe to all of them, passing·········+/** Emits the last value the {@link Source} emitted, whenever the notifier Source emits a value.+* `sample` will store the latest value the {@link Source} emitted. Every time the `notifier` Source+* This is a back pressure operator that can be used to omit values from a {@link Source} coming in+* {@link Source | Sources} emitting `undefined` are undefined behaviour and these values will be···+* @param reducer - A function called with the last value by the `reducer` and the emitted value.+* `scan` accepts a reducer function and a seed value. The reducer will be called initially with the+* seed value and the first emitted value. The {@link Source} will then emit the value returned by+* the reducer function. Subsequently, the `reducer` is called with the last value the `reducer`+* This operator is similar to `Array.prototype.reduce`, but instead is called over time and emitsexport function scan<In, Out>(reducer: (acc: Out, value: In) => Out, seed: Out): Operator<In, Out> {···+* `share` accepts a {@link Source} and returns one. It will emit all values as normal, however, it···+* `skip` will skip `wait` number of emitted values, then issue all values as normal afterwards.······+* function returns `false`. When the `predicate` function returns `false`, the Source's values will···+* returned. If a value is emitted while the last returned Source is still active, the prior Source+* This can be used to issue multiple values per emission of an input {@link Source}, while only···+* `switchAll` accepts a {@link Source} which must emit {@link Source | Sources}. Each time it+* receives a {@link Source} it will close its prior subscription and subscribe to the new Source+* `take` will issue all values as normal until the `max` number of emitted values has been reached.···+* `takeLast` will buffer values from the input {@link Source} up until the given `max` number. It···+* `takeUntil` will issue all values as normal from the input {@link Source} until the `notifier`···+* `takeWhile` will issue all values as normal from the input {@link Source} until the `predicate`+* function returns `false`. When the `predicate` function returns `false`, the current value is···+* `debounce` accepts a mapping function that can be used to return a time (in ms) per emitted+* value. All emitted values issued by the {@link Source} during the returned time will be omitted+* Debouncing means that the returned {@link Source} will wait for a minimum time of silence until a+* This is a back pressure operator that can be used to omit values from a {@link Source} coming in···+* `delay` accepts a time (in ms) by which each {@link SignalKind | signal} will be delayed by.+* Since the operator only calls `setTimeout` per signal, it relies on the timeout implementation to···+* `throttle` accepts a mapping function that can be used to return a time (in ms) per emitted+* value. During the returned timeframe all values issued by the {@link Source} will be omitted and+* This is a back pressure operator that can be used to omit values from a {@link Source} coming in
+155
-130
src/pipe.ts
+155
-130
src/pipe.ts
···
···+* The `pipe` utility can be called with a {@link Source} then one or more unary transform functions.+* Each transform function will be called in turn with the last function's return value, starting+* It's used to transform a source with a list of {@link Operator | Operators}. The last argument may+* @see {@link https://github.com/tc39/proposal-pipeline-operator} for the JS Pipeline Operator spec, for which this is a replacement utility for.
+122
src/sinks.ts
+122
src/sinks.ts
···············
···+/** Creates a subscription to a given source and invokes a `subscriber` callback for each value.+* `subscribe` accepts a `subscriber` callback and returns a function accepting a {@link Source}.+* When a source is passed to the returned funtion, the subscription will start and `subscriber`+* will be called for each new value the Source issues. This will also return a {@link Subscription}···+/** Creates a subscription to a given source and invokes a `subscriber` callback for each value.+* When a source is passed to the returned funtion, the subscription will start and `subscriber`+/** Creates a subscription to a given source and invokes a `subscriber` callback for each value.···+* `toAsyncIterable` will create an {@link AsyncIterable} that pulls and issues values from a given+* {@link Source}. This can be used in many interoperability situations, to provide an iterable when+* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols}···+* `toArray` accepts a {@link Source} and returns an array of all synchronously issued values from+* this Source. It will issue {@link TalkbackKind.Pull | Pull signals} after every value it receives+* added to the array and a {@link TalkbackKind.Close | Close signal} is issued by the sink before···+/** Subscribes to a given source and returns a Promise that will resolve with the last value the+* `toPromise` will subscribe to the passed {@link Source} and resolve to the last value of it once+* To keep its implementation simple, padding sources that don't issue any values to `toPromise` is
+206
-4
src/sources.ts
+206
-4
src/sources.ts
···························
···+* At times it's necessary to create a {@link Source} lazily. The time of a {@link Source} being+* creation and subscription time. This is especially useful when the Source we wrap is "hot" and+* @example An example of creating a {@link Source} that issues the timestamp of subscription. Here+* create a Source that issues the time of its subscription, rather than the time of its creation+* @see {@link fromIterable | `fromIterable`} for the non-async Iterable version of this helper,+* {@link AsyncIterable}. This can be used in many interoperability situations, including to consume+* When the {@link Sink} throws an exception when a new value is pushed, this helper will rethrow it+* using {@link AsyncIterator.throw}, which allows an async generator to recover from the exception.+* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols}···+* @see {@link fromAsyncIterable | `fromAsyncIterable`} for the AsyncIterable version of this helper.+* {@link Iterable | JS Iterable}. As iterables are the common standard for any lazily iterated list+* This Source will only call {@link Iterator.next} on the iterator when the subscribing {@link Sink}+* This helper will call {@link fromAsyncIterable | `fromAsyncIterable`} automatically when the+* When the {@link Sink} throws an exception when a new value is pushed, this helper will rethrow it+* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol}···+* `fromArray` will create a {@link Source} that issues the values of a given JS array one by one. It+* will issue values as they're pulled and is hence a "cold" source, not eagerly emitting values. It+* will end and issue the {@link SignalKind.End | End signal} when the array is exhausted of values.···+* The `subscriber` function receives an {@link Observer}. You may call {@link Observer.next} to+* Your `subscribr` function must return a {@link TeardownFn | teardown function} which is only+* called when your source is cancelled — not when you invoke `complete` yourself. As this creates a+* "cold" source, every time this source is subscribed to, it will invoke the `subscriber` function···+* `makeSubject` creates a new {@link Subject}. A Subject is a {@link Source} and an {@link Observer}+* combined in one interface, as the Observer is used to send new signals to the Source. This means+* that it's "hot" and hence all subscriptions to {@link Subject.source} share the same underlying···+* `empty` is a {@link Source} that immediately issues an {@link SignalKind.End | End signal} when···+* `never` is a {@link Source} that never issues any signals and neither sends values nor ends.+* `interval` will create a {@link Source} that issues an incrementing counter each time the `ms`···+* @returns A {@link Source} issuing the {@link Event | DOM Events} as they're issued by the DOM.+* `fromDomEvent` will create a {@link Source} that listens to the given element's events and issues···+* `fromPromise` will create a {@link Source} that issues the {@link Promise}'s resolving value
+161
-9
src/types.ts
+161
-9
src/types.ts
···-/** A talkback signal is used to tell a [Source] that either the [Sink] is ready for new values or that the stream should be cancelled */-/** A talkback callback is sent to the sink with the [Start] signal to communicate signals back to the source. */-/** The start [Signal] is the first signal and carries a callback (talkback) so the sink can send signals to the source */-/** A sink accepts new values from a [Source], like [Push], [Start], and an end signal. The [Start] is used to receive a callback to send talkback signals back to the source. */-/** An operator transforms a [Source] and returns a new [Source], potentially with different timings or output types. */
···+* This signal is issued via {@link TalkbackFn | talkback functions} that a {@link Sink} receives via+* the {@link Start} signal, to tell a {@link Source} to either send a new value (pulling) or stop+* This function sends a {@link TalkbackKind} signal to the source to instruct it to send a new value+* This is used, in particular, in the {@link make | make Source} and is a returned function that is+* This signal is issued by a {@link Source} and {@link Sink | Sinks} are called with it. The signals+* This starts the stream of values and carries a {@link TalkbackFn | talkback function} with it+* Informs the {@link Sink} that the {@link Source} has ended and that it won't send more values.+* sources don't have a set end or limit on how many values will be sent. This signal is not sent+* when the {@link Source} is cancelled with a {@link TalkbackKind.Close | Close talkback signal}.+* This signal is sent from a {@link Source} to a {@link Sink} at the start of a stream to inform it+* {@link TalkbackFn | talkback function} that is used by the {@link Sink} to communicate back to the+* This signal is sent from a {@link Source} to a {@link Sink} to send a new value to it. This is+* Signals are sent from {@link Source | Sources} to {@link Sink | Sinks} to inform them of changes.+* A {@link Source}, when consumed, sends a sequence of events to {@link Sink | Sinks}. In order, a+* {@link SignalKind.Start | Start} signal will always be sent first, followed optionally by one or+* {@link Source} will send the {@link SignalKind.End | End signal} when it runs out of values. The+* A Sink is a function that is called repeatedly with signals from a {@link Source}. It represents+/** Factory function that calls {@link Sink | Sinks} with {@link Signal | Signals} when invoked.+* {@link Start | Start signal} that sends a talkback function to the {@link Sink}, so it may request+* Wonka comes with several helper operators that transform a given {@link Source} into a new one,+* accepts arguments and then returns this kind of function, so they can be chained and composed.+* @see {@link TalkbackKind.Close | Close signal} This uses the {@link TalkbackFn | talkback function} to send a {@link TalkbackKind.Close | Close signal}+* to the subscribed-to {@link Source} to stop it from sending new values. This cleans up the subscription+* The Observer is used whenever a utility allows for signals to be sent manually as a {@link Source}+* This creates an {@link SignalKind.End | End signal} that is sent to a {@link Sink}. The Observer+* will accept no more values via {@link Observer.next | `next` calls} once this method has been+/** Subjects combine a {@link Source} with the {@link Observer} that is used to send values on said Source.+* {@link Observer}'s methods to send signals, as well as the `source` to receive said signals.