synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
20 lines • 1.11 kB
TypeScript
import { Patch } from 'json-joy/lib/json-crdt';
import { CompactCodecPatch } from 'json-joy/lib/json-crdt-patch/codec/compact';
/**
* Calculates the size in bytes of the UTF-8 string representation of a compact-encoded JSON CRDT Patch.
* This is useful for determining the size of patch that will be sent in a WebSocket connection, which requires UTF-8
* encoding.
* @param patch the compact-encoded JSON CRDT Patch
* @returns the size in bytes of the UTF-8 string representation of the patch
*/
export declare function getPatchSizeInBytes(patch: CompactCodecPatch): number;
/**
* Given a json-joy JSON CRDT Patch, splits it into multiple patches if its compact encoding
* exceeds the specified maximum size in bytes.
* @param patch
* @param maxPatchSizeBytes
* @returns An array of patches that are compact-encoded. Each patch is guaranteed to be within the specified size limit, or to only contain
* a single operation if it cannot be split further.
*/
export declare function splitPatch(patch: Patch, maxPatchSizeBytes: number): CompactCodecPatch[];
//# sourceMappingURL=splitPatch.d.ts.map