<commit_before>/**
 * Synchronise two worlds via message passing
 */
function WorldSyncer(world) {
  this.world = world;

  this.changeRecordFilter = function (record) {
    return record && record.owner && record.owner === world.identifier;
  };
}

/**
 * WorldSyncer.workerParent is an interface for connecting to the main thread that spawned the current
 * web worker. Pass it to connectToWorker within your webworker
 */
WorldSyncer.WorkerParent = function() {
  this.addMessageHandler = function(handler) {
    addEventListener("message", this.messageListener = function (event) {
      handler(event.data);
    });
  };

  this.removeMessageHandler = function(handler) {
    if(this.messageListener) {
      removeEventListener("message", this.messageListener);
    }
  };

  this.postMessage = function(message) {
    postMessage(message);
  };
};

/**
 * Sync interface via a websocket
 */
WorldSyncer.Socket = function(socket) {

  this.addMessageHandler = function(handler) {
    socket.on('worldSync', this.worldSyncListener = function(message) {
      handler(message);
    });
  };

  this.removeMessageHandler = function() {
    if (this.worldChangeListener) {
      handler.off('worldSync', this.worldSyncListener);
      delete this.worldChangeListener;
    }
  }

  this.postMessage = function(message) {
    socket.emit('worldSync', message);
  };

}
<commit_msg>Use raw websocket for world syncing<commit_after>/**
 * Synchronise two worlds via message passing
 */
function WorldSyncer(world) {
  this.world = world;

  this.changeRecordFilter = function (record) {
    return record && record.owner && record.owner === world.identifier;
  };
}

/**
 * WorldSyncer.workerParent is an interface for connecting to the main thread that spawned the current
 * web worker. Pass it to connectToWorker within your webworker
 */
WorldSyncer.WorkerParent = function() {
  this.addMessageHandler = function(handler) {
    addEventListener("message", this.messageListener = function (event) {
      handler(event.data);
    });
  };

  this.removeMessageHandler = function(handler) {
    if(this.messageListener) {
      removeEventListener("message", this.messageListener);
    }
  };

  this.postMessage = function(message) {
    postMessage(message);
  };
};

/**
 * Sync interface via a websocket
 */
WorldSyncer.Socket = function(socket) {

  this.addMessageHandler = function(handler) {
    socket.on('message', this.worldSyncListener = function(message) {
      handler(message);
    });
  };

  this.removeMessageHandler = function() {
    if (this.worldChangeListener) {
      handler.off('message', this.worldSyncListener);
      delete this.worldChangeListener;
    }
  }

  this.postMessage = function(message) {
    socket.send(message);
  };

}

{'fraction_non_alphanumeric': 0.12323816407661728, 'fraction_numerical': 0.0, 'mean_word_length': 3.7641996557659207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5067232', 'n_tokens_mistral': 791, 'n_tokens_neox': 776, 'n_words': 172}