splitDataPath()function
splitDataPath(path: BranchDataPath<T> | BranchDataSegments<T>): BranchDataSegments<T>
splitDataPath(path: LeafDataPath<T> | LeafDataSegments<T>): LeafDataSegments<T>
splitDataPath(path: string | Segments): Segments
| Param | Type | |
|---|---|---|
path | BranchDataPath<T>BranchDataSegments<T> | The dotted path string (e.g. "a.b") or an array of segments. required |
path | LeafDataPath<T>LeafDataSegments<T> | required |
path | stringSegments | 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"]