splitDataPath()function

splitDataPath(path: BranchDataPath<T> | BranchDataSegments<T>): BranchDataSegments<T>
splitDataPath(path: LeafDataPath<T> | LeafDataSegments<T>): LeafDataSegments<T>
splitDataPath(path: string | Segments): Segments
ParamType
pathBranchDataPath<T>
BranchDataSegments<T>
The dotted path string (e.g. "a.b") or an array of segments. required
pathLeafDataPath<T>
LeafDataSegments<T>
required
pathstring
Segments
required
Return
BranchDataSegments<T>
The path as an array of segments.
LeafDataSegments<T>
Typed path tuple for only leaf nodes of a data object. i.e. LeafPath<{ a: number, b: { c: string } }> produces readonly ["a"] | readonly ["b", "c"]
Segments
Series of string segments with at least one segment (this is what you actually get back when you split a string).

Split a dotted path into data path segments.

  • A path that is already an array of segments is returned unchanged.

Examples

splitDataPath<{ a: { b: number } }>("a.b"); // ["a", "b"]