mobx-keystone
Version:
A MobX powered state management solution based on data trees with first class support for TypeScript, snapshots, patches and much more
46 lines (45 loc) • 1.29 kB
TypeScript
import { Path } from '../parent/pathTypes';
import { Patch } from './Patch';
export type JsonPatch = JsonPatchAddOperation<any> | JsonPatchRemoveOperation | JsonPatchReplaceOperation<any>;
export interface JsonPatchBaseOperation {
path: string;
}
export interface JsonPatchAddOperation<T> extends JsonPatchBaseOperation {
op: "add";
value: T;
}
export interface JsonPatchRemoveOperation extends JsonPatchBaseOperation {
op: "remove";
}
export interface JsonPatchReplaceOperation<T> extends JsonPatchBaseOperation {
op: "replace";
value: T;
}
/**
* Converts a path into a JSON pointer.
*
* @param path Path to convert.
* @returns Converted JSON pointer.
*/
export declare function pathToJsonPointer(path: Path): string;
/**
* Converts a JSON pointer into a path.
*
* @param jsonPointer JSON pointer to convert.
* @returns Converted path.
*/
export declare function jsonPointerToPath(jsonPointer: string): Path;
/**
* Convert a patch into a JSON patch.
*
* @param patch A patch.
* @returns A JSON patch.
*/
export declare function patchToJsonPatch(patch: Patch): JsonPatch;
/**
* Converts a JSON patch into a patch.
*
* @param jsonPatch A JSON patch.
* @returns A patch.
*/
export declare function jsonPatchToPatch(jsonPatch: JsonPatch): Patch;