UNPKG

immutable-json-patch

Version:

Immutable JSON patch with support for reverting operations

46 lines 1.82 kB
import type { JSONPatchDocument, JSONPatchOperation, JSONPatchOptions, JSONPath, JSONPointer } from './types'; /** * Apply a patch to a JSON object * The original JSON object will not be changed, * instead, the patch is applied in an immutable way */ export declare function immutableJSONPatch<T, U = unknown>(document: U, operations: JSONPatchDocument, options?: JSONPatchOptions): T; /** * Replace an existing item */ export declare function replace<T, U, V>(document: U, path: JSONPath, value: V): T; /** * Remove an item or property */ export declare function remove<T, U>(document: U, path: JSONPath): T; /** * Add an item or property */ export declare function add<T, U, V>(document: U, path: JSONPath, value: V): T; /** * Copy a value */ export declare function copy<T, U>(document: U, path: JSONPath, from: JSONPath): T; /** * Move a value */ export declare function move<T, U>(document: U, path: JSONPath, from: JSONPath): T; /** * Test whether the data contains the provided value at the specified path. * Throws an error when the test fails */ export declare function test<T, U>(document: T, path: JSONPath, value: U): void; export declare function isArrayItem(document: unknown, path: JSONPath): document is Array<unknown>; /** * Resolve the path index of an array, resolves indexes '-' * @returns Returns the resolved path */ export declare function resolvePathIndex<T>(document: T, path: JSONPath): JSONPath; /** * Validate a JSONPatch operation. * Throws an error when there is an issue */ export declare function validateJSONPatchOperation(operation: JSONPatchOperation): void; export declare function parsePath<T>(document: T, pointer: JSONPointer): JSONPath; export declare function parseFrom(fromPointer: JSONPointer): JSONPath; //# sourceMappingURL=immutableJSONPatch.d.ts.map