Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as observablesWithStreams from "https://raw.githubusercontent.com/surma/observables-with-streams/28c55be6d855780c677fd1f4ba975f4d3144891d/src/index.ts";

§Variables

EOF

Symbol indicating the end of a stream. Used with external.

§Functions

amb

Takes in multiple observables but only emits items from the first observable to emit.

buffer

Collects items from the original observable into buffers until the notifier emits. If no items have been buffered since the last time the notifier emitted, nothing will be emitted. Closing the emitter will emit the remaining buffer.

bufferWithCount

Collects items from the original observable into buffers of size count.

collect

Collects all values from the observable into an array.

combineLatest

Combines items from multiple observables. The resulting observable emits array tuples whenever any of the given observables emit, as long as every observable has emitted at least once. The tuples contain the last emitted item from each observable.

combineLatestWith

Combines items from the original observable with the other observables. See combineLatest.

concat

Creates an output Observable which sequentially emits all values from given Observable and then moves on to the next.

concatAll

Converts a higher-order Observable into a first-order Observable by concatenating the inner Observables in order.

debounce

Returns a Transform where items are only emitted if ms milliseconds pass without new a new emit by the source observable. If a new value is emitted, the “cooldown” is restarted and the old value is discarded.

discard

Sink for observables that discards all values. Useful to leave at the end of a chain.

distinct

Returns a Transform where all subsequent repetitions of the same item are filtered out.

endWith

Returns a Transform that emits the items specified as arguments after te source observable ends.

exhaust

Converts a higher-order Observable into a first-order Observable by dropping inner Observables while the previous inner Observable has not yet completed.

external

Utility function to create new observables from external sources. Returns an object with two values: the new observable, and a next function which will emit a value to observable when called. Calling next with EOF will indicate there are no more values to emit.

extractFirst

Resolves with the first element emitted by the observable, then releases the observable. If no items are emitted the promise is rejected.

extractLast

Resolves with the last element emitted by the observable. If no items are emitted the promise is rejected.

filter

Returns a Transform that emits all items for which f returns true.

first

Returns a Transform that emits the first item in an observable. The source observable will be drained after.

forEach

Calls a function for each item emitted by an observable without waiting for the function to return to forward the item. Exceptions thrown by the function will be caught and ignored.

forkJoin

Combines items from multiple observables. The resulting observable emits array tuples whenever any of the given observables emit, as long as every observable has emitted at least once. The tuples contain the last emitted item from each observable.

fromAsyncFunction

Creates an observable from an asynchronous function. The observable emits exactly one value when once the function returns.

fromEvent

Creates an observable from an EventTarget. Each event is turned into an item for the observable.

fromGenerator

Creates an observable from a generator that takes no arguments.

fromIterable

Creates an observable from a synchronous iterable.

fromNext

Creates an observable from a function that gets passed the observable's next() function.

fromPromise

Creates an observable from a promise, that emits exactly one value when the promise resolves.

fromTimer

Creates an observable that will forever emit null every ms milliseconds.

just

Creates an observable that emits a set of values.

last

Returns a Transform that emits the last item in an observable.

map

Returns a Transform with the results of applying the given function to each emitted item of the original observable.

merge

Merges multiple observables by emitting all items from all the observables. Items are emitted in the order they appear.

mergeWith

Merges another observable by emitting all items from both the original observable and the other observable. Items are emitted in the order they appear.

of

An alias for just.

race

Alias for amb.

range

Creates an observable that emits numbers from start to end.

reduce

Accumulates value, starting with v0 and applying f to each emitted item. If no items are emitted the promise is rejected.

repeat

Creates an observable that forever emits the same value.

sample

Emits the most recently emitted value from the Observable whenever the notifier emits. If no new value has been emitted from the source observable since the last time the notifier emitted, nothing will be emitted.

scan

Reduces the original observable with f, emitting every intermediate result not including the initial value.

single

Resolves with the only element emitted by the observable. If zero or more than one items are emitted, the promise is rejected.

subchain

Returns a Transform that applies f to the observable.

subscribe

Alias for discard.

switchAll

Converts a higher-order Observable into a first-order Observable producing values only from the most recent observable sequence.

switchMap

Converts each emitted item to an observable, producing values only from the most recent observable in the sequence.

take

Returns a Transform that emits the first n items from the original observable.

takeWhile

Returns a Transform that emits items from the original observable until f returns false.

tap

Alias for forEach.

window

Branches out the source observable as nested observables whenever notifier emits.

zip

Zips items from multiple observables. The resulting observable emits items as array tuples.

zipWith

Zips items from the original observable with the other observable. See zip.

§Type Aliases

NextFunc
Observable

An Observable in the sense of ReactiveX. The signature, however, does not match the one precedented in ReactiveX and other languages. In its current incarnation, Observables are synonymous with WHATWG ReadableStream.

ScanFunc
Transform