data-to-jsonschema-to-ts
Version:
Convert plain javascript objects to JSON Schema and TypeScript typings
25 lines • 1.02 kB
TypeScript
type Primitive = string | number | boolean | null | undefined;
/**
* Walk an object or array, invoking the callback for each **primitive leaf**
* (`string`, `number`, `boolean`, `null`, `undefined`).
*
* The callback receives:
* - `value` — the primitive
* - `jsonPath` — dot/bracket notation path (e.g. `"profile.name"`, `"tags[0]"`)
* - `meta` — `{ key, parent? }` where `parent` describes the containing object/array
*
* Useful for redaction, indexing, or path-based diffing of plain JSON-like objects.
*
* @param obj - The object or array to traverse.
* @param handlePrimitive - Called once per primitive leaf.
* @param currentPath - Used internally for recursion. Don't pass.
*/
export declare function traverseObject(obj: object | object[], handlePrimitive: (value: Primitive, jsonPath: string, meta: {
key: string | number;
parent?: {
path: string;
type: "object" | "array";
};
}) => void, currentPath?: string): void;
export {};
//# sourceMappingURL=index.d.ts.map