"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decode = exports.decoder = exports.encode = exports.encoder = void 0;
const Encoder_1 = require("./Encoder");
const Decoder_1 = require("./Decoder");
const CrdtWriter_1 = require("../../util/binary/CrdtWriter");
/** A shared instance of the {@link CrdtWriter} class. */
const writer = new CrdtWriter_1.CrdtWriter(1024 * 4);
/** A shared instance of the {@link Encoder} class. */
exports.encoder = new Encoder_1.Encoder(writer);
/**
 * Encodes a JSON CRDT Patch into a binary {@link Uint8Array} blob.
 *
 * @param patch A {@link Patch} to encode.
 * @returns A Uint8Array containing the encoded patch.
 */
const encode = (patch) => {
    return exports.encoder.encode(patch);
};
exports.encode = encode;
/** A shared instance of the {@link Decoder} class. */
exports.decoder = new Decoder_1.Decoder();
/**
 * Decodes a binary {@link Uint8Array} blob into a JSON CRDT Patch.
 *
 * @param buf Binary blob to decode.
 * @returns A {@link Patch} decoded from the binary blob.
 */
const decode = (buf) => {
    return exports.decoder.decode(buf);
};
exports.decode = decode;
//# sourceMappingURL=shared.js.map