json-joy
    Preparing search index...

    Class PatchBuilder

    Utility class that helps in Patch construction.

    Index

    Constructors

    Properties

    clock: IClock

    Clock to use for generating timestamps.

    patch: Patch

    The patch being constructed.

    Methods

    • Given a JSON value creates the necessary builder commands to create JSON CRDT Patch operations to construct the value. If the value is a timestamp, it is returned as-is. If the value is a JSON primitive is a number, boolean, or null, it is converted to a "con" data type. Otherwise, the value is converted using the PatchBuilder.json method.

      Parameters

      • value: unknown

        A JSON value for which to create JSON CRDT Patch construction operations.

      Returns ITimestampStruct

      ID of the root constructed CRDT object.

    • Creates a "con" data type unless the value is already a timestamp, in which case it is returned as-is.

      Parameters

      • value: unknown

        Value to convert to a "con" data type.

      Returns Timestamp

      ID of the new "con" object.

    • Retrieve the sequence number of the next timestamp.

      Returns number

      The next timestamp sequence number that will be used by the builder.

    • Add padding "noop" operation if clock's time has jumped. This method checks if clock has advanced past the ID of the last operation of the patch and, if so, adds a "noop" operation to the patch to pad the gap.

      Returns void