KeyPath
KeyPath =
KeyPath.Component|KeyPath.Self
Defined in: keyPath.ts:11, keyPath.ts:13
Key paths represent paths to access nested properties in an object
Key paths can be either:
- A dot-notation string representing nested properties (e.g. "user.address.street")
- A special Self symbol representing the current object
Component
Section titled “Component”Component =
string&object
Defined in: keyPath.ts:15
Branded type for key path components
Type Declaration
Section titled “Type Declaration”[keyPathBrand]
Section titled “[keyPathBrand]”[keyPathBrand]:
unknown
Self =
symbol&object
Defined in: keyPath.ts:17, keyPath.ts:19
Branded type for a self-referencing key path
Type Declaration
Section titled “Type Declaration”[keyPathBrand]
Section titled “[keyPathBrand]”[keyPathBrand]:
unknown
Static Members
Section titled “Static Members”Self:
KeyPath.Self
Defined in: keyPath.ts:17, keyPath.ts:19
Self path symbol
build()
Section titled “build()”build(...
keys):KeyPath
Defined in: keyPath.ts:41
Build a key path from an array of keys
Parameters
Section titled “Parameters”...(string | number | KeyPath | null)[]
Returns
Section titled “Returns”KeyPath
The constructed key path
Remarks
Section titled “Remarks”- Joins keys with dots
- Ignores null values
- Ignores empty strings
- Handles KeyPath.Self
getAncestors()
Section titled “getAncestors()”getAncestors(
keyPath,includeSelf?):Generator<KeyPath>
Defined in: keyPath.ts:97
Get all ancestors of a key path
Parameters
Section titled “Parameters”keyPath
Section titled “keyPath”KeyPath
includeSelf?
Section titled “includeSelf?”boolean = true
Whether to include the path itself
Returns
Section titled “Returns”Generator<KeyPath>
- KeyPath.Self for single-level paths when
includeSelfis false - Key paths starting from the closest ancestor and moving up to the root
getParentKey()
Section titled “getParentKey()”getParentKey(
keyPath):KeyPath
Defined in: keyPath.ts:82
Get the parent key of a key path
Parameters
Section titled “Parameters”keyPath
Section titled “keyPath”KeyPath
Returns
Section titled “Returns”KeyPath
The parent key or a self path if the key path is a self path
getRelative()
Section titled “getRelative()”getRelative(
keyPath,prefixKeyPath):KeyPath|null
Defined in: keyPath.ts:70
Get the relative key path from a prefix key path
Parameters
Section titled “Parameters”keyPath
Section titled “keyPath”KeyPath
prefixKeyPath
Section titled “prefixKeyPath”KeyPath
Returns
Section titled “Returns”KeyPath | null
nullif the key path is not a child of the prefix- KeyPath.Self if the paths are identical
- The original path if the prefix is KeyPath.Self
isSelf()
Section titled “isSelf()”isSelf(
keyPath):keyPathisKeyPath.Self
Defined in: keyPath.ts:26
Whether a key path is a self path
Empty strings are also considered self paths.
Parameters
Section titled “Parameters”keyPath
Section titled “keyPath”KeyPath
Returns
Section titled “Returns”keyPath is KeyPath.Self