merge-change
Version:
Advanced library for deep merging, patching, and immutable updates of data structures. Features declarative operations for specific merging behaviors, property management, custom type merging rules, and difference tracking. Supports complex data transform
13 lines (12 loc) • 870 B
TypeScript
import { ExtractPathsAny, PathToType } from '../common-types/types';
/**
* Retrieves the value at the specified path in a deeply nested data structure. If the path does not exist,
* the function returns the provided default value.
*
* @param data - The data object or array from which to retrieve the value.
* @param path - The path string to the desired value, with parts separated by the specified separator.
* @param [defaultValue=undefined] - The value to return if the path does not exist.
* @param [separator='.'] - The string used to separate path segments. Defaults to '.'.
* @return The value at the specified path in the data structure or the default value if the path is invalid.
*/
export declare function get<D, P extends ExtractPathsAny<D, S>, S extends string = '.'>(data: D, path: P, defaultValue?: unknown, separator?: S): PathToType<D, P, S>;