package @rimbu/common
The @rimbu/common
package provides many commonly used types and utilities that can also be of use to Rimbu users.
Interfaces
Name | Description |
---|---|
Comp<K> | An object providing methods to compare two values of type K . |
ToJSON<V,D> | Utility type to convert some object to a JSON serializable format. |
TraverseState | An object used to track the state of a traversal, e.g. a forEach . |
Namespaces
Name | Description |
---|---|
AsyncOptLazy | A potentially lazy and/or asynchronous value of type T. |
CollectFun | A function used in collect methods to collect values from a collection. This is basically a single-pass map and filter. |
Comp | An object providing methods to compare two values of type K . |
Eq | A function returning true if given v1 and v2 should be considered equal. |
ErrBase | undocumented |
IndexRange | A flexible range specification for numeric indices. If a start or end is defined, a tuple can be used where the second item is a boolean indicating whether that end is inclusive or exclusive. |
An IndexRange can have one of the following forms:
- { amount: number }
- { start: number }
- { start: number, amount: number }
- { start: number, end: number }
- { start: number, end: [number, boolean] }
- { start: [number, boolean] }
- { start: [number, boolean], amount: number }
- { start: [number, boolean], end: number }
- { start: [number, boolean], end: [number, boolean] }
- { end: number }
- { end: [number, boolean] }
|
|
Range
| A range definition for any type of (orderable) value. If a start or end is defined, a tuple can be used where the second item is a boolean indicating whether that end is inclusive (true) or exclusive (false). A Range of type T can have one of the following forms: - { end: T }
- { end: [T, boolean] }
- { start: T }
- { start: T, end: T }
- { start: T, end: [T, boolean] }
- { start: [T, boolean] }
- { start: [T, boolean], end: T }
- { start: [T, boolean], end: [T, boolean] } |
Functions
Err
Throws an Err.ForcedError
error when called.
Err
Err.ForcedError
error when called.OptLazy
Returns the value contained in an OptLazy
instance of type T.
OptLazy
OptLazy
instance of type T.OptLazyOr
Returns the value contained in an OptLazyOr
instance of type T, or the given otherValue
if the lazy function returns it.
OptLazyOr
OptLazyOr
instance of type T, or the given otherValue
if the lazy function returns it.TraverseState
Returns a new TraverseState
instance, using optionally given startIndex
as a start index value.
TraverseState
TraverseState
instance, using optionally given startIndex
as a start index value.Update
Returns the result of given update
parameter, where it can either directly give a new value, or it is a function receiving the given value
, and returns a new value.
Update
update
parameter, where it can either directly give a new value, or it is a function receiving the given value
, and returns a new value.