UNPKG

@winglet/json

Version:

TypeScript library for safe and efficient JSON data manipulation with RFC 6901 (JSON Pointer) and RFC 6902 (JSON Patch) compliance, featuring prototype pollution protection and immutable operations

39 lines (38 loc) 1.06 kB
export declare const Operation: { readonly ADD: "add"; readonly REPLACE: "replace"; readonly REMOVE: "remove"; readonly MOVE: "move"; readonly COPY: "copy"; readonly TEST: "test"; }; export type Operation = (typeof Operation)[keyof typeof Operation]; interface BasePatch { op: Operation; path: string; } export interface TestPatch<Value> extends BasePatch { op: typeof Operation.TEST; value: Value; } export interface AddPatch<Value> extends BasePatch { op: typeof Operation.ADD; value: Value; } export interface ReplacePatch<Value> extends BasePatch { op: typeof Operation.REPLACE; value: Value; } export interface RemovePatch extends BasePatch { op: typeof Operation.REMOVE; } export interface CopyPatch extends BasePatch { op: typeof Operation.COPY; from: string; } export interface MovePatch extends BasePatch { op: typeof Operation.MOVE; from: string; } export type Patch = TestPatch<any> | AddPatch<any> | ReplacePatch<any> | RemovePatch | MovePatch | CopyPatch; export {};