@webkrafters/get-property
Version:
Get property - gets an object containing value and search feedback info matching a property path. Recognizes negative array indexing.
17 lines (16 loc) • 733 B
TypeScript
export type KeyType = number | string | symbol;
export interface PropertyInfo<T = unknown> {
_value: unknown;
exists: boolean;
index: number;
isSelf: boolean;
key: KeyType;
source: unknown;
trail: Array<KeyType>;
value: T;
}
declare function getProperty<V = unknown>(source: unknown, path?: Array<KeyType>, defaultValue?: V): PropertyInfo<V>;
declare function getProperty<V = unknown>(source: unknown, path?: symbol, defaultValue?: V): PropertyInfo<V>;
declare function getProperty<V = unknown>(source: unknown, path?: string, defaultValue?: V): PropertyInfo<V>;
declare function getProperty<V = unknown>(source: unknown, path?: number, defaultValue?: V): PropertyInfo<V>;
export default getProperty;