package @rimbu/deep
The @rimbu/deep
package provides utilities to patch and match plain JavaScript objects.
See the Rimbu docs Deep overview page for more information.
Interfaces
Name | Description |
---|---|
WithType<T> | Typed and curried Deep API, used in situations where the target type is known but the value will be applied later. |
Namespaces
Name | Description |
---|---|
Deep | undocumented |
Match | The type to determine the allowed input values for the match function. |
Patch | A type to determine the allowed input type for the patch function. |
Path | undocumented |
Selector | Type defining the allowed selectors on an object of type T . Selectors can be: - a path string into type T . - a function receiving a Protected version of type T , and returning an arbitrary value. - a tuple of Selectors for type T - an object where the property values are Selectors for type T . |
Tuple | A readonly array of fixed length and types. |
Functions
getAt
Returns the value resulting from selecting the given path
in the given source
object. It supports optional chaining for nullable values or values that may be undefined, and also for accessing objects inside an array. There is currently no support for forcing non-null (the !
operator).
getAt
path
in the given source
object. It supports optional chaining for nullable values or values that may be undefined, and also for accessing objects inside an array. There is currently no support for forcing non-null (the !
operator).getAtWith
Returns a function that gets the value at the given string path
inside an object.
getAtWith
path
inside an object.match
Returns true if the given value
object matches the given matcher
, false otherwise.
match
value
object matches the given matcher
, false otherwise.matchAt
Returns true if the given value
object matches the given matcher
at the given path
, false otherwise.
matchAt
value
object matches the given matcher
at the given path
, false otherwise.matchAtWith
Returns a function that matches a given value
with the given matcher
at the given string path
.
matchAtWith
value
with the given matcher
at the given string path
.matchWith
Returns a function that matches a given value
with the given matcher
.
matchWith
value
with the given matcher
.patch
Returns an immutably updated version of the given value
where the given patchItems
have been applied to the result. The Rimbu patch notation is as follows: - if the target is a simple value or array, the patch can be the same type or a function returning the same type - if the target is a tuple (array of fixed length), the patch be the same type or an object containing numeric keys with patches indicating the tuple index to patch - if the target is an object, the patch can be the same type, or an array containing partial keys with their patches for the object
patch
value
where the given patchItems
have been applied to the result. The Rimbu patch notation is as follows: - if the target is a simple value or array, the patch can be the same type or a function returning the same type - if the target is a tuple (array of fixed length), the patch be the same type or an object containing numeric keys with patches indicating the tuple index to patch - if the target is an object, the patch can be the same type, or an array containing partial keys with their patches for the objectpatchAt
Patches the value at the given path in the source to the given value. Because the path to update must exist in the source
object, optional chaining and array indexing is not allowed.
patchAt
source
object, optional chaining and array indexing is not allowed.patchAtWith
Returns a function that patches a given value
with the given patchItems
at the given path
.
patchAtWith
value
with the given patchItems
at the given path
.patchWith
Returns a function that patches a given source
with the given patchItems
.
patchWith
source
with the given patchItems
.protect
Returns the same value wrapped in the Protected
type.
protect
Protected
type.select
Returns the result of applying the given selector
shape to the given source
value.
select
selector
shape to the given source
value.selectAt
Returns the result of applying the given selector
shape to the given source
value.
selectAt
selector
shape to the given source
value.selectAtWith
Returns a function that selects a certain shape from a given value
with the given selector
at the given string path
.
selectAtWith
value
with the given selector
at the given string path
.selectWith
Returns a function that selects a certain shape from a given value
with the given selector
.
selectWith
value
with the given selector
.withType
Returns a curried API with a known target type. This can be useful for using the methods in contexts where the target type can be inferred from the usage.
withType