@mfederczuk/deeptools
Version:
A set of utility functions that recursively operate on objects
23 lines (22 loc) • 901 B
TypeScript
import { NonEmptyArray } from "./_internal/utils";
import type { GenericKey } from "./types";
export type KeyPath = NonEmptyArray<GenericKey>;
export type PropertyVisitorFunc = (path: KeyPath, value: unknown, parentObject: unknown, descriptor: PropertyDescriptor, rootObject: unknown) => void;
export type DeepWalkOptions = {
/**
* Before visiting an object, visit all of its properties.
*
* Default value is `false`.
*/
depth?: boolean;
};
/**
* Recursively walks through **obj**.
*
* ### This is an experimental function, use with caution. ###
*
* @param obj The object to walk through.
* @param visitorFunc The visitor callback function to call on every property.
* @param options Options object to change the behavior of `deepWalk`.
*/
export declare function deepWalk(obj: unknown, visitorFunc: PropertyVisitorFunc, options?: Readonly<DeepWalkOptions>): void;