Utility Module
Type aliases
A callback function that is called with 0...n
arguments
Type parameters
-
T: unknown
The type of the value from a source
Type declaration
-
-
Parameters
-
Rest ...args: T[]
Returns void
-
-
A function used to map values to a modified value, either of the same type (String.toUpperCase) or of a different type (Number.parseInt)
Type parameters
-
T = unknown
The type of value as input to the method
-
K = T | unknown
The type of value returned from the method
Type declaration
-
-
Parameters
-
value: T
Returns K
-
-
A function that takes one or more parameters and returns a boolean value based on the function calculation
Type parameters
-
T: unknown
The type of the value being checked
Type declaration
-
-
Parameters
-
Rest ...args: T[]
Returns boolean
-
-
A function passed to debounceWithQuery as the second parameter, takes a string and returns an Observable source
Type parameters
-
T = unknown
The response from an API which returns the result of a query
Type declaration
-
-
Parameters
-
query: string
Returns ObservableInput < T >
-
-
Colour Functions
-
Returns an Observable that emits a string containing a
rgb
orrgba
colour (ifalpha
is included in the sting or as a property) converted from a source hex stringParameters
-
Optional alpha: Subscribable<number> | number
Optional Alpha to include if converting 3-part hex colours to rgba
Returns MonoTypeOperatorFunction < string >
Observable that emits a string containing a HTML hex colour
-
-
Returns an Observable that emits a string containing a HTML hex colour converted from a source rgb string
Parameters
-
Optional excludeHash: Subscribable<boolean> | boolean
Optional boolean to exclude the hash (
#
) character from the return result
Returns MonoTypeOperatorFunction < string >
Observable that emits a string containing a HTML hex colour
-
-
Returns an Observable that emits a string containing a HTML hex colour converted from a source rgba string
Parameters
-
Optional excludeHash: Subscribable<boolean> | boolean
Optional boolean to exclude the hash (
#
) character from the return result
Returns MonoTypeOperatorFunction < string >
Observable that emits a string containing a HTML hex colour
-
Conversion Functions
-
Returns an Observable that converts the source value through Lengths conversion
Type parameters
-
I: SupportedLengths
-
O: SupportedLengths
Parameters
-
fromLength: Subscribable<I> | I
The length type of the source value
-
toLength: Subscribable<O> | O
The length type of the output value
-
precision: Subscribable<number> | number = 3
The number of decimal places to return, default is
3
Returns MonoTypeOperatorFunction < number >
Observable that emits a number that is the
from
Lengths converted to theto
Lengths -
-
Returns an Observable that emits a number based on the version of the source value through Temperatures conversion
Type parameters
-
I: SupportedTemperatures
String or Temperatures value for the input value
-
O: SupportedTemperatures
String or Temperatures value for the output value
Parameters
-
fromTemperature: Subscribable<I> | I
The temperature type to convert from
-
toTemperature: Subscribable<O> | O
The temperature type to convert from
-
precision: Subscribable<number> | number = 2
The number of decimal places to return, default is
1
Returns MonoTypeOperatorFunction < number >
Observable that emits a number that is the
from
Temperatures converted to theto
Temperatures -
-
Returns an Observable that converts the source value through Weights conversion
Type parameters
-
I: SupportedWeights
String or Weights value for the input value
-
O: SupportedWeights
String or Weights value for the output value
Parameters
-
fromWeight: Subscribable<I> | I
The weight type of the source value
-
toWeight: Subscribable<O> | O
The weight type of the output value
-
precision: Subscribable<number> | number = 2
The number of decimal places to return, default is
2
Returns MonoTypeOperatorFunction < number >
Observable that emits a number that is the
from
Weights converted to theto
Weights -
HTTP Functions
-
Returns an Observable from fetch that emits a number during the progress of the file download and once finished emits a Uint8Array
Parameters
-
input: RequestInfo
A
string
url or Request object -
init: RequestInit = ...
Optional
RequestInit
dictionary -
controller: AbortController = ...
Optional AbortController used to cancel any outstanding requests
Returns Observable < number | Uint8Array >
-
Mapping Functions
-
Returns an Observable value from a remote source where the QueryMethod returns a result such as a search from a remote location
Type parameters
-
T: unknown
The response from an API which returns the result of a query
Parameters
-
time: number
The debounce time before the query method is executed
-
queryMethod: QueryMethod<T>
The method that returns the search
Returns OperatorFunction < string , T >
An Observable that emits a value from a server request
-
-
Returns an Observable that emits an object from a parsed JWT token
Type parameters
-
T: Record<string, unknown>
The known JWT response object
Returns OperatorFunction < string , T >
Observable that emits a decoded JWT token body
-
-
Returns an Observable that emits the value from either the
trueResult
orfalseResult
based on the result from the source with a PredicateFn.Type parameters
-
I: unknown
The type of value from the source
-
T = unknown
The type returned from the Truthy result
-
F = unknown
The type returned from the Falsy result
Parameters
-
predicate: PredicateFn<I>
The method to check the value from the source Observable
-
trueResult: MapFn<I, T>
The method with return value for a truthy PredicateFn
-
falseResult: MapFn<I, F>
The method with return value for a falsy PredicateFn
Returns OperatorFunction < I , T | F >
Observable that emits a value from the truthy or falsy MapFn based on the PredicateFn result
-
-
Returns an Observable that emits the value from either the
trueResult
orfalseResult
based on the result from the source with a PredicateFn.Type parameters
-
I: unknown
The type of value from the source
-
T = unknown
The type returned from the Truthy result
-
F = unknown
The type returned from the Falsy result
Parameters
-
predicate: PredicateFn<I>
The method to check the value from the source Observable
-
trueResult: MapFn<I, Subscribable<T>>
The method with return value for a truthy PredicateFn
-
falseResult: MapFn<I, Subscribable<F>>
The method with return value for a falsy PredicateFn
Returns OperatorFunction < I , T | F >
Observable that emits a value based on the PredicateFn result
-
Side Effects Functions
-
Perform a side effect for every emit from the source Observable that passes the PredicateFn, return an Observable that is identical to the source.
Type parameters
-
T: unknown
The value type of the source
Parameters
-
predicate: PredicateFn<T>
PredicateFn function to compared the values against
-
callback: CallbackFn<T>
CallbackFn to be executed when this operator is run
Returns MonoTypeOperatorFunction < T >
Observable that emits the source observable after performing a side effect
-
-
Perform a side effect for the first subscription to the source Observable, return an Observable that is identical to the source.
Type parameters
-
T: unknown
The value type of the source
Parameters
-
callback: CallbackFn<undefined>
CallbackFn to be executed when this operator is run
Returns MonoTypeOperatorFunction < T >
Observable that emits the source observable after performing a side effect
-
-
Perform a side effect for every subscription to the source Observable and return an Observable that is identical to the source.
Type parameters
-
T: unknown
The value type of the source
Parameters
-
callback: CallbackFn<undefined>
CallbackFn to be executed when this operator is run
Returns MonoTypeOperatorFunction < T >
Observable that emits the source observable after performing a side effect
-
-
Perform a side effect for every unsubscription to the source Observable and return an Observable that is identical to the source.
Type parameters
-
T: unknown
The value type of the source
Parameters
-
callback: CallbackFn<undefined>
CallbackFn to be executed when this operator is run
Returns MonoTypeOperatorFunction < T >
Observable that emits the source Observable and calls the
callback
on unsubscription -
Streams Functions
-
Returns an Observable that emits values from an EventSource subscribing to the the passed
eventName
stream. Takes an optional Observer (e.g. Subject) to emit when the stream opensType parameters
-
T: unknown
The type of the value in the message
data
property
Parameters
-
source: EventSource
The event source to subscribe to
-
eventName: string = 'message'
The name of the event to listen to, by default this is
message
-
Optional openObserver: Observer<Event>
Optional observer that is emitted when the event source is opened
-
Optional signal: AbortSignal
Optional signal to end the event source
Returns Observable < T >
Observable that emits the
data
value from an EventSource message -
-
Creates an Observable source from a ReadableStream source that will emit any values emitted by the stream.
Type parameters
-
T: unknown
Parameters
-
stream: ReadableStream<T>
The ReadableStream to subscribe to
-
Optional signal: AbortSignal
Optional AbortSignal to provide to the underlying stream
-
Optional queueStrategy: QueuingStrategy
Optional strategy for backpressure queueing
-
throwEndAsError: boolean = false
Optional to return an error when the
AbortSignal
has been fired instead of just closing
Returns Observable < T >
Observable that emits from a ReadableStream source
-
-
Returns an Observable that emits the response from a source connected to via the Web Serial API. The function can also accept an Observable that emits values to write to the serial device, allowing two-way communication.
Both the input and output values must be Uint8Array, you can use TextEncoder and TextDecoder to convert between strings, which can be seen in the demo
The function will also handle opening and closing of the port from the serial device when using an
AbortSignal
or ending the RxJS subscription.Parameters
-
port: SerialPort
The SerialPort object to connect to
-
Optional writerSource: Observable<Uint8Array>
Optional Observable source to emit values to the serial connection writer
-
Optional options: SerialOptions
Options for the connection - if none passed a default
baudRate
of9600
is set -
Optional signal: AbortSignal
Optional signal to end the source
Returns Observable < Uint8Array >
Observable that emits the output from a serial source
-
-
Returns the source Observable, emitting it through the passed WritableStream and handling the internal subscription state and error handling. If passed an AbortSignal the WritableStream can be ended early without ending the entire subscription
Type parameters
-
T: unknown
Parameters
-
stream: WritableStream<T> | WritableStreamDefaultWriter<T>
The Writer object to emit the data to
-
Optional signal: AbortSignal
Optional signal used to end the writer without ending the rest of the stream
Returns MonoTypeOperatorFunction < T >
Observable that emits the source observable after performing a write to the WritableStream
-
Subscription Functions
-
Returns the source Observable that will use the passed AbortSignal to handle unsubscription
Type parameters
-
T: unknown
The value of the Observable
Parameters
-
signal: AbortSignal
The signal used to end the subscription
Returns MonoTypeOperatorFunction < T >
Observable that will end subscription when the AbortSignal has been fired
-
Generated using TypeDoc, the 18/11/2022 at 13:22:58
Package containing utility operators for use with RxJS covering various categories such as side effects, handling streams and converting values.