readSyncMessage = (decoder, encoder, doc, transactionOrigin) => {
  const messageType = decoding.readVarUint(decoder);

  switch (messageType) {
    case messageYjsSyncStep1:
      readSyncStep1(decoder, encoder, doc);
      break;

    case messageYjsSyncStep2:
      readSyncStep2(decoder, doc, transactionOrigin);
      break;

    case messageYjsUpdate:
      readUpdate(decoder, doc, transactionOrigin);
      break;

    default:
      throw new Error('Unknown message type');
  }

  return messageType;
}
@param {decoding.Decoder} decoder A message received from another client
@param {encoding.Encoder} encoder The reply message. Will not be sent if empty.
@param {Y.Doc} doc
@param {any} transactionOrigin