Stream239
Constructors
callbackconstCreates a stream from a callback that can emit values into a queue.dieconstThe stream that dies with the specified defect.emptyconstCreates an empty stream.failconstTerminates with the specified error.failCauseconstCreates a stream that fails with the specified Cause.failCauseSyncconstThe stream that always fails with the specified lazily evaluated Cause.failSyncconstTerminates with the specified lazily evaluated error.fromArrayconstCreates a stream from an array of values.fromArrayEffectconstCreates a stream from an effect that produces an array of values.fromArraysconstCreates a stream from an arbitrary number of arrays.fromAsyncIterableconstCreates a stream from an AsyncIterable.fromChannelconstCreates a stream from a array-emitting Channel.fromEffectconstCreates a stream from an effect.fromEffectDrainconstCreates a stream that runs the effect and emits no elements.fromEffectRepeatconstCreates a stream from an effect producing a value of type A which repeats forever.fromEffectScheduleconstCreates a stream from an effect producing a value of type A, which is repeated using the specified schedule.fromEventListenerconstCreates a stream from an event listener.fromIterableconstCreates a new Stream from an iterable collection of values.fromIterableEffectconstCreates a stream from an effect producing an iterable of values.fromIterableEffectRepeatconstCreates a stream by repeatedly running an effect that yields an iterable of values.fromIteratorSucceedconstCreates a stream that consumes values from an iterator.fromPubSubconstCreates a stream from a subscription to a PubSub.fromPubSubTakeconstCreates a stream from a PubSub of Take values.fromPullconstCreates a stream from a pull effect, such as one produced by Stream.toPull.fromQueueconstCreates a stream that pulls values from a Queue.Dequeue.fromReadableStreamconstCreates a stream from a lazily supplied Web ReadableStream.fromScheduleconstCreates a stream that emits each output of a schedule that does not require input, for as long as the schedule continues.fromSubscriptionconstCreates a stream from a PubSub subscription.iterateconstCreates an infinite stream by repeatedly applying a function to a seed value.makeconstCreates a stream from a sequence of values.neverconstThe stream that never produces any value or fails with any error.paginateconstCreates a stream by repeatedly evaluating an effectful page function.rangeconstConstructs a stream from a range of integers, including both endpoints.scopedconstRuns a stream that requires Scope in a managed scope, ensuring its finalizers are run when the stream completes.succeedconstCreates a single-valued pure stream.suspendconstCreates a lazily constructed stream.syncconstCreates a stream that synchronously evaluates a function and emits the result as a single value.tickconstCreates a stream that emits void immediately once, then emits another void after each specified interval.toChannelconstCreates a channel from a stream.transformPullconstDerives a stream by transforming its pull effect.transformPullBracketconstTransforms a stream by effectfully transforming its pull effect.unfoldconstCreates a stream by repeatedly applying an effectful step function to a state.unwrapconstCreates a stream produced from an Effect.Services
provideconstProvides a layer or context to the stream, removing the corresponding service requirements.provideContextconstProvides multiple services to the stream using a context.provideServiceconstProvides the stream with a single required service, eliminating that requirement from its environment.provideServiceEffectconstProvides a service to the stream using an effect, removing the requirement and adding the effect's error and environment.updateContextconstTransforms the stream's required services by mapping the current context to a new one.updateServiceconstUpdates a single service in the stream environment by applying a function.Models
EventListenerinterfaceInterface representing an event listener target.HaltStrategytypeDescribes how merged streams decide when to halt.StreaminterfaceA Stream<A, E, R> describes a program that can emit many A values, fail with E, and require R.StreamUnifyinterfaceType-level unification hook for Stream within the Effect type system.StreamUnifyIgnoreinterfaceType-level marker that excludes Stream from unification.VarianceinterfaceType-level variance marker for Stream.VarianceStructinterfaceStructural encoding used by Variance to record each Stream type parameter's variance.Type Ids
Guards
Mapping
flatMapconstMaps each element to a stream and flattens the resulting streams.flattenconstFlattens a stream of streams into a single stream.flattenEffectconstFlattens a stream of Effect values into a stream of their results.flattenIterableconstFlattens the iterables emitted by this stream into the stream's structure.mapconstTransforms the elements of this stream using the supplied function.mapAccumconstMaps elements statefully, emitting zero or more outputs per input.mapAccumArrayconstMaps over non-empty chunk arrays statefully, emitting zero or more values per chunk.mapAccumArrayEffectconstMaps each non-empty input chunk statefully and effectfully, emitting zero or more output values per chunk.mapAccumEffectconstMaps each element statefully and effectfully, emitting zero or more output values per input.mapArrayconstTransforms each emitted chunk using the provided function, which receives the chunk and its index.mapArrayEffectconstMaps over non-empty array chunks emitted by the stream effectfully.mapBothconstMaps both the failure and success channels of a stream.mapEffectconstMaps over elements of the stream with the specified effectful function.Filtering
dropconstDrops the first n elements from this stream.dropRightconstDrops the last specified number of elements from this stream.dropUntilconstDrops elements until the specified predicate evaluates to true, then drops that matching element.dropUntilEffectconstDrops all elements of the stream until the specified effectful predicate evaluates to true.dropWhileconstDrops elements from the stream while the specified predicate evaluates to true.dropWhileEffectconstDrops elements while the specified effectful predicate evaluates to true.dropWhileFilterconstDrops elements while the filter succeeds.filterconstFilters a stream to the elements that satisfy a predicate.filterEffectconstFilters elements in a single pass effectfully.filterMapconstFilters and maps stream elements in one pass using a Filter.filterMapEffectconstFilters and maps elements in one pass effectfully using a FilterEffect.partitionconstSplits a stream into scoped excluded and satisfying substreams using a Filter.partitionEffectconstSplits a stream with an effectful Filter, returning scoped streams for filter successes and failures.partitionQueueconstPartitions a stream using a Filter and exposes passing and failing values as scoped queues.takeconstTakes the first n elements from this stream, returning Stream.empty when n < 1.takeRightconstKeeps the last n elements from this stream.takeUntilconstTakes elements until the predicate matches.takeUntilEffectconstTakes stream elements until an effectful predicate returns true.takeWhileconstTakes the longest initial prefix of elements that satisfy the predicate.takeWhileEffectconstTakes elements from the stream while the effectful predicate is true.takeWhileFilterconstTakes the longest initial prefix accepted by a Filter and emits the filter's success values.whenconstReturns the specified stream if the given condition is satisfied, otherwise returns an empty stream.Sequencing
combineArrayconstCombines two streams chunk-by-chunk with a stateful pull function.concatconstConcatenates two streams, emitting all elements from the first stream followed by all elements from the second stream.drainconstConverts this stream to one that runs its effects but emits no elements.drainForkconstRuns the provided stream in the background while this stream runs, interrupting it when this stream completes and failing if the background stream fails or defects.flattenArrayconstFlattens a stream of non-empty arrays into a stream of elements.flattenTakeconstUnwraps Take values, emitting elements from non-empty arrays and ending or failing when the Exit signals completion.foreverconstRepeats this stream forever.intersperseconstInserts the provided element between emitted elements.intersperseAffixesconstAdds a start value, middle value, and end value around stream elements.onEndconstRuns the provided effect when the stream ends successfully.onFirstconstRuns the provided effect with the first element emitted by the stream.onStartconstRuns the provided effect before this stream starts.prependconstPrepends the values from the provided iterable before the stream's elements.repeatconstRepeats the entire stream according to the provided schedule.repeatElementsconstRepeats each element of the stream according to the provided schedule, including the original emission.switchMapconstSwitches to the latest stream produced by the mapping function, interrupting the previous stream when a new element arrives.tapconstRuns the provided effect for each element while preserving the elements.tapBothconstReturns a stream that effectfully "peeks" at elements and failures.tapSinkconstRuns a sink for all stream elements while still emitting them downstream.Destructors
mkStringconstConcatenates all emitted strings into a single string.mkUint8ArrayconstConcatenates the stream's Uint8Array chunks into a single Uint8Array.peelconstRuns a sink to peel off enough elements to produce a value and returns that value with the remaining stream in a scope.runconstRuns a stream with a sink and returns the sink result.runCollectconstRuns the stream and collects all elements into an array.runCountconstRuns the stream and returns the number of elements emitted.runDrainconstRuns the stream for its effects, discarding emitted elements.runFoldconstRuns the stream and folds elements using a pure reducer.runFoldEffectconstRuns the stream and folds elements using an effectful reducer.runForEachconstRuns the provided effectful callback for each element of the stream.runForEachArrayconstConsumes the stream in chunks, passing each non-empty array to the callback.runForEachWhileconstRuns the stream, applying the effectful predicate to each element and stopping when it returns false.runHeadconstRuns the stream and returns the first element as an Option.runIntoPubSubconstRuns the stream, publishing elements into the provided PubSub.runIntoQueueconstRuns the stream, offering each element to the provided queue and ending it with Cause.Done when the stream completes.runLastconstRuns the stream and returns the last element as an Option.runSumconstRuns the stream and returns the numeric sum of its elements.toAsyncIterableconstConverts a stream to an AsyncIterable for for await...of consumption.toAsyncIterableEffectconstCreates an effect that yields an AsyncIterable using the current services.toAsyncIterableWithconstConverts the stream to an AsyncIterable using the provided services.toPubSubconstConverts a stream to a PubSub of emitted values for concurrent consumption.toPubSubTakeconstConverts a stream to a PubSub of Take values for concurrent consumption.toPullconstReturns a scoped pull for manually consuming the stream's output chunks.toQueueconstCreates a scoped dequeue that is fed by the stream for concurrent consumption.toReadableStreamconstConverts a stream to a ReadableStream.toReadableStreamEffectconstCreates an Effect that builds a ReadableStream from the stream.toReadableStreamWithconstConverts the stream to a ReadableStream using the provided services.Context
Accumulation
accumulateconstAccumulates elements into a growing array, emitting the cumulative array for each input chunk.collectconstCollects all elements into an array and emits it as a single element.scanconstAccumulates state across the stream, emitting the initial state and each updated state.scanEffectconstAccumulates state effectfully and emits the initial state plus each accumulated state.Aggregation
aggregateconstAggregates elements using the provided sink and emits each sink result as a stream element.aggregateWithinconstAggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.transduceconstApplies a sink transducer to the stream and emits each sink result.Broadcast
broadcastconstCreates a PubSub-backed stream that multicasts the source to all subscribers.broadcastNconstCreates a fixed-size tuple of streams that each emit the same elements as the source stream.shareconstReturns a new Stream that multicasts the original stream, subscribing when the first consumer starts.Constants
Deduplication
changesconstEmits only elements that differ from the previous one.changesWithconstReturns a stream that only emits elements that are not equal to the previously emitted element, as determined by the specified predicate.changesWithEffectconstEmits only elements that differ from the previous element, using an effectful equality check.Do Notation
bindconstBinds the result of a stream to a field in the do-notation record.bindEffectconstBinds an Effect-produced value into the do-notation record for each stream element.bindToconstMaps each element into a record keyed by the provided name.DoconstProvides the entry point for do-notation style stream composition.Encoding
Error Handling
catchCauseconstSwitches over to the stream produced by the provided function in case this one fails.catchCauseFilterconstRecovers from stream failures by filtering the Cause and switching to a recovery stream.catchCauseIfconstRecovers from stream failures by filtering the Cause and switching to a recovery stream.catchFilterconstRecovers from errors that match a Filter by switching to a recovery stream.catchIfconstRecovers from errors that match a predicate by switching to a recovery stream.catchReasonconstCatches a specific reason within a tagged error.catchReasonsconstCatches multiple reasons within a tagged error using an object of handlers.catchTagconstRecovers from failures whose _tag matches the provided value by switching to the stream returned by f.catchTagsconstSwitches to a recovery stream based on matching _tag handlers.ignoreconstIgnores failures and ends the stream on error.ignoreCauseconstIgnores the stream's failure cause, including defects, and ends the stream.mapErrorconstTransforms the errors emitted by this stream using f.onErrorconstRuns the provided effect when the stream fails, passing the failure cause.orDieconstTurns typed failures into defects, making the stream infallible.orElseIfEmptyconstSwitches to a fallback stream if this stream is empty.orElseSucceedconstReturns a stream that emits a fallback value when this stream fails.resultconstLifts failures and successes into a Result, yielding a stream that cannot fail.retryconstRetries the stream according to the given schedule when it fails.tapCauseconstRuns an effect when the stream fails without changing its values or error, unless the tap effect itself fails.tapErrorconstPeeks at errors effectfully without changing the stream unless the tap fails.withExecutionPlanconstApplies an ExecutionPlan to a stream, retrying with step-provided resources until it succeeds or the plan is exhausted.Finalization
Grouping
chunksconstExposes the underlying chunks as a stream of non-empty arrays.groupAdjacentByconstGroups consecutive elements that have equal keys into non-empty arrays.groupByconstGroups elements into keyed substreams using an effectful classifier.groupByKeyconstGroups elements by a key and emits a stream per key.groupedconstPartitions the stream into non-empty arrays of the specified size.groupedWithinconstPartitions the stream into arrays, emitting when the chunk size is reached or the duration passes.rechunkconstGroups the stream into arrays of the specified size, preserving element order.slidingconstEmits a sliding window of n elements.slidingSizeconstEmits sliding windows of chunkSize elements, advancing by stepSize.splitconstSplits the stream into non-empty groups whenever the predicate matches.Interruption
Merging
combineconstCombines elements from this stream and the specified stream by repeatedly applying a stateful function that can pull from either side.interleaveconstInterleaves this stream with the specified stream by alternating pulls from each stream; when one ends, the remaining values from the other stream are emitted.interleaveWithconstInterleaves two streams deterministically by following a boolean decider stream.mergeconstMerges two streams, emitting elements from both as they arrive.mergeAllconstMerges a collection of streams, running up to the specified number concurrently.mergeEffectconstMerges this stream with a background effect, keeping the stream's elements.mergeLeftconstMerges two streams while emitting only the values from the left stream.mergeResultconstMerges this stream and the specified stream together, tagging values from the left stream as Result.succeed and values from the right stream as Result.fail.mergeRightconstMerges this stream and the specified stream together, emitting only the values from the right stream while the left stream runs for its effects.Pipe
pipeThroughconstPipes the stream through Sink.toChannel, emitting only the sink leftovers.pipeThroughChannelconstPipes this stream through a channel that consumes and emits chunked elements.pipeThroughChannelOrFailconstPipes values through the provided channel while preserving this stream's failures alongside any channel failures.Racing
Rate Limiting
bufferconstBuffers up to capacity elements so a faster producer can progress independently of a slower consumer.bufferArrayconstAllows a faster producer to progress independently of a slower consumer by buffering up to capacity chunks in a queue.debounceconstDrops earlier elements within the debounce window and emits only the latest element after the pause.scheduleconstSchedules the stream's elements according to the provided schedule.throttleconstRate-limits stream chunks with a synchronous cost function.throttleEffectconstRate-limits stream chunks with an effectful cost function.timeoutconstEnds the stream if it does not produce a value within the specified duration.timeoutOrElseconstSwitches to a fallback stream if this stream does not emit a value within the specified duration.Tracing
Type Lambdas
Utility Types
Zipping
crossconstCreates the cartesian product of two streams, running the right stream for each element in the left stream.crossWithconstCreates a cartesian product of elements from two streams using a function.zipconstZips this stream with another point-wise and emits tuples of elements from both streams.zipFlattenconstZips this stream with another point-wise and emits tuples of elements from both streams, flattening the left tuple.zipLatestconstCombines two streams by emitting each new element with the latest value from the other stream.zipLatestAllconstZips multiple streams so that when a value is emitted by any stream, it is combined with the latest values from the other streams to produce a result.zipLatestWithconstCombines the latest values from both streams whenever either emits, using the provided function.zipLeftconstZips this stream with another point-wise and keeps only the values from the left stream.zipRightconstZips this stream with another point-wise, keeping only right values and ending when either stream ends.zipWithconstZips two streams point-wise with a combining function, ending when either stream ends.zipWithArrayconstZips two streams by applying a function to non-empty arrays of elements.zipWithIndexconstZips this stream together with the index of elements.zipWithNextconstZips each element with the next element, pairing the final element with Option.none().zipWithPreviousconstZips each element with its previous element, starting with None.zipWithPreviousAndNextconstZips each element with its previous and next values.