arvo-event-handler
Version:
Type-safe event handler system with versioning, telemetry, and contract validation for distributed Arvo event-driven architectures, featuring routing and multi-handler support.
38 lines (37 loc) • 1.31 kB
TypeScript
/**
* Represents a path and its corresponding value in an object.
* @property {string[]} path - An array of strings representing the path to the value.
* @property {any} value - The value found at the specified path.
*/
export type PathValue = {
path: string[];
value: any;
};
/**
* Recursively retrieves all paths and their corresponding values from an object.
*
* @param {Record<string, any>} obj - The object from which paths are extracted.
* @returns {PathValue[]} An array of PathValue, each containing a path and its corresponding value.
* @throws {Error} Will throw an error if `obj` is not a string or an object.
*
* @example
* const obj = { a: { b: 1 }, c: 2 };
* const paths = getAllPaths(obj);
* // paths = [
* // { path: ['a', 'b'], value: 1 },
* // { path: ['c'], value: 2 }
* // ]
*/
export declare function getAllPaths(obj: Record<string, any>): PathValue[];
/**
* Converts a PathValue object to a string representation.
*
* @param {PathValue} item - The PathValue object to convert.
* @returns {string} A string representation of the PathValue.
*
* @example
* const pathValue = { path: ['a', 'b'], value: 1 };
* const result = pathValueToString(pathValue);
* // result = "#a.#b.1"
*/
export declare const pathValueToString: (item: PathValue) => string;