UNPKG

lodash-walk-object

Version:

Walk all properties deep in object with lodash help

113 lines (111 loc) 3.66 kB
// @ts-nocheck interface Circ { /** * Path whose value points to an already visited object. */ pathToObj: string; /** * Lodash path of the original object. */ circuralTargetPath: string | unknown; } interface Models__NS__InDBType { target: object; path: string; } interface Models__NS__Ver { v: unknown; p: string; parent?: Models__NS__Ver; isGetter?: boolean; /** * Active ancestor chain used by breadth-first traversal when * shared objects should not be treated as circular. */ ancestors?: Models__NS__InDBType[]; } interface Models__NS__StartIteratorOptions { walkGetters?: boolean; /** * When false, every repeated object reference is treated as circular. * * When true, only references to objects in the current ancestor chain * are treated as circular. Shared objects are walked for every path. * * @default false */ considerSharedObjects?: boolean; /** * Circular checking is especially useful for breadth-first traversal. */ checkCircural?: boolean; breadthWalk?: boolean; include?: string[]; exclude?: string[]; } interface Models__NS__AdditionalIteratorOptions extends Models__NS__StartIteratorOptions { skipObject?: () => void; isGetter?: boolean; /** * Breadth walk skips the contents of circular objects. */ isCircural?: boolean; exit?: () => void; } interface Models__NS__InternalValues extends Models__NS__AdditionalIteratorOptions { stack?: Models__NS__InDBType[]; circural?: Circ[]; hasIterator?: boolean; _valueChanged: boolean; _skip: boolean; _exit: boolean; } type Iterator = (value: unknown, lodashPath: string, changeValueTo: (newValue: unknown) => void, options?: Models__NS__AdditionalIteratorOptions) => void; type UnknownRecord = Record<PropertyKey, unknown>; interface PreparedPath { contextPath: string; property: string | number; } interface PropertyEntry { key: string; value: unknown; isGetter: boolean; } declare class Helpers { static get Walk(): { Object(json: object, iterator: Iterator, options?: Models__NS__StartIteratorOptions): { circs: Circ[] | undefined; }; ObjectBy(property: string, inContext: object, iterator: Iterator, options?: Models__NS__StartIteratorOptions): { circs: Circ[] | undefined; }; }; private static createInternalOptions; private static _walk; private static walkDepthFirst; private static walkBreadthFirst; private static prepareCurrentValue; private static findChildren; private static getPropertyEntries; private static readProperty; private static appendPath; private static propertyToPath; private static shouldSkipPath; private static normalizeRootArrayPath; private static isSamePathOrDescendant; private static isAncestorPath; private static _changeValue; private static _prepareParams; private static get _Helpers(); private static isObjectLike; } declare const walk: { Object: (json: object, iterator: Iterator, options?: Models__NS__StartIteratorOptions) => { circs: Circ[] | undefined; }; ObjectBy: (property: string, inContext: object, iterator: Iterator, options?: Models__NS__StartIteratorOptions) => { circs: Circ[] | undefined; }; }; export { Helpers, walk }; export type { Circ, Iterator, Models__NS__AdditionalIteratorOptions, Models__NS__InDBType, Models__NS__InternalValues, Models__NS__StartIteratorOptions, Models__NS__Ver, PreparedPath, PropertyEntry, UnknownRecord };