Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/deep/internal.ts

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
import * as rimbu from "https://deno.land/x/rimbu@0.13.5/deep/internal.ts";

Variables

Regular expression used to split a path string into tokens.

Regular expression used to split a path string into tokens.

Functions

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).

Returns a function that gets the value at the given string path inside an object.

Returns true if the given value object matches the given matcher, false otherwise.

Returns true if the given value object matches the given matcher at the given path, false otherwise.

Returns a function that matches a given value with the given matcher at the given string path.

Returns a function that matches a given value with the given matcher.

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

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.

Returns a function that patches a given value with the given patchItems at the given path.

Returns a function that patches a given source with the given patchItems.

Return the given path string split into an array of subpaths.

Returns the same value wrapped in the Protected type.

Returns the result of applying the given selector shape to the given source value.

Returns the result of applying the given selector shape to the given source value.

Returns a function that selects a certain shape from a given value with the given selector at the given string path.

Returns a function that selects a certain shape from a given value with the given selector.

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.

Return the given path string split into an array of subpaths.

Interfaces

Typed and curried Deep API, used in situations where the target type is known but the value will be applied later.

Type Aliases

The type to determine the allowed input values for the match function.

The type that determines allowed matchers for arrays/tuples.

Keys used to indicate an array match traversal.

Defines an object containing exactly one CompoundType key, having an array of matchers.

Compount matcher for objects, can only be an array staring with a compound type keyword.

Compound keys used to indicate the type of compound.

Determines the various allowed match types for given type T.

Utility type for collecting match failure reasons

Type used to determine the allowed function types. Always includes booleans.

The type that determines allowed matchers for objects.

The type to determine allowed matchers for object properties.

Defines an object containing exactly one TraversalType key, having a matcher for the array element type.

Type used to indicate an object containing matches for tuple indices.

A type that either directly results in result type S or is a function taking the value, parent, and root values, and returns a value of type S.

A type to determine the allowed input type for the patch function.

The entry type for a (nested) patch. Can be either a patch object or a function accepting the nested patch function and returning a patch object.

A function patch type that is a function taking the current value, the parent and root values, and returns a return value.

Utility type to exclude Iterable types.

A type defining the allowed patch values for objects.

A type defining the allowed patch values for object properties.

A type defining the allowed patch values for tuples.

Either result type S, or a patch function with the value type, the parent type, and the root type.

A string representing a path into an (nested) object of type T.

Utility type to only add non-empty string types to a string array.

Determines the allowed paths for an array.

Determines the allowed paths into a value of type T.

Determines whether the given type T is optional, that is, whether it can be null or undefined.

Returns type T if Maybe is false, T | undefined otherwise.

Determines the allowed non-empty paths into a value of type T.

Determines the allowed paths into a non-optional value of type T.

Determines the allowed paths for an object.

Determines the allowed path part seperator based on the input types.

Determines the allowed paths for a tuple. Since tuples have fixed types, they do not need to be optional, in contrast to arrays.

The result type when selecting from object type T a path with type P.

Determines the result type for an array of tokens representing subpaths in type T.

Determines the result of getting the property/index K from type T, taking into account that the value may be optional.

Converts a path string into separate tokens in a string array.

A string representing a path into an (nested) object of type T.

The allowed values of a split path.

A deep readonly typed version of given type T. Makes all properties or elements read only. It maps types using the following rules:

  • arrays and tuples become readonly counterparts, and all element types are wrapped in Protected if applicable
  • Maps of key type K and value type V become Maps of key type Protected<K> and value type Protected<V>
  • Sets of element type E become Sets of element type Protected<E>
  • Promises of value type E become Promises of value type Protected<E>
  • Objects that have only simple properties (no functions or iterators) will have all the properties as Protected if applicable
  • Any other type will not be mapped

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.

Type defining the result type of applying the SL selector type to the T value type.

Type defining the shape of allowed selectors, used to improve compiler checking.

The type to determine the allowed input values for the match function.

The type that determines allowed matchers for arrays/tuples.

Keys used to indicate an array match traversal.

Defines an object containing exactly one CompoundType key, having an array of matchers.

Compount matcher for objects, can only be an array staring with a compound type keyword.

Compound keys used to indicate the type of compound.

Determines the various allowed match types for given type T.

Utility type for collecting match failure reasons

Type used to determine the allowed function types. Always includes booleans.

The type that determines allowed matchers for objects.

The type to determine allowed matchers for object properties.

Defines an object containing exactly one TraversalType key, having a matcher for the array element type.

Type used to indicate an object containing matches for tuple indices.

A type that either directly results in result type S or is a function taking the value, parent, and root values, and returns a value of type S.

A type to determine the allowed input type for the patch function.

The entry type for a (nested) patch. Can be either a patch object or a function accepting the nested patch function and returning a patch object.

A function patch type that is a function taking the current value, the parent and root values, and returns a return value.

Utility type to exclude Iterable types.

A type defining the allowed patch values for objects.

A type defining the allowed patch values for object properties.

A type defining the allowed patch values for tuples.

Either result type S, or a patch function with the value type, the parent type, and the root type.

A string representing a path into an (nested) object of type T.

Utility type to only add non-empty string types to a string array.

Determines the allowed paths for an array.

Determines the allowed paths into a value of type T.

Determines whether the given type T is optional, that is, whether it can be null or undefined.

Returns type T if Maybe is false, T | undefined otherwise.

Determines the allowed non-empty paths into a value of type T.

Determines the allowed paths into a non-optional value of type T.

Determines the allowed paths for an object.

Determines the allowed path part seperator based on the input types.

Determines the allowed paths for a tuple. Since tuples have fixed types, they do not need to be optional, in contrast to arrays.

The result type when selecting from object type T a path with type P.

Determines the result type for an array of tokens representing subpaths in type T.

Determines the result of getting the property/index K from type T, taking into account that the value may be optional.

Converts a path string into separate tokens in a string array.

A string representing a path into an (nested) object of type T.

The allowed values of a split path.

A deep readonly typed version of given type T. Makes all properties or elements read only. It maps types using the following rules:

  • arrays and tuples become readonly counterparts, and all element types are wrapped in Protected if applicable
  • Maps of key type K and value type V become Maps of key type Protected<K> and value type Protected<V>
  • Sets of element type E become Sets of element type Protected<E>
  • Promises of value type E become Promises of value type Protected<E>
  • Objects that have only simple properties (no functions or iterators) will have all the properties as Protected if applicable
  • Any other type will not be mapped

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.

Type defining the result type of applying the SL selector type to the T value type.

Type defining the shape of allowed selectors, used to improve compiler checking.