Skip to main content

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

NameDescription
Literal<T>Type to represent Literal values for the match and patch functions.

Namespaces

NameDescription
LiteralType to represent Literal values for the match and patch functions.
MatchType to determine the allowed input type for the match functions.
PatchType to determine the allowed input type for the patch function.
PathA string representing a path into an (nested) object of type T.
TupleA readonly array of fixed length and types.

Functions

Immutable

Returns the same value wrapped in the Immutable type

Definition

export declare function Immutable<T>(value: T): Immutable<T>;

Type parameters

NameDescription
T

Parameters

NameTypeDescription
valueTthe value to wrap

patch

Returns an updated version of given value, without modifying the value, where the contents are updated according to the given patches Patch array.

Definition

export declare function patch<T>(value: T): (...patches: Patch.Multi<T>) => T;

Type parameters

NameDescription
Tthe type of the value to patch

Parameters

NameTypeDescription
valueTthe value to update
example
patch({ g: { h: 5 }})({ g: { h: 6 }})          // => { g: { h: 6 }}
patch({ g: { h: 5 }})({ g: { h: v => v + 1 }}) // => { g: { h: 6 }}
patch({ g: { h: 5 }})({ g: { h: 1 }}, { g: { h: v => v + 1 }})
// => { g: { h: 2 }}
patch({ a: 1, b: 3 })({ a: (v, p) => v * p.b, (v, p) => v + p.a })
// => { a: 3, b: 4 }