<commit_before>(function() {

  function $WebSocketBackend() {
    var connectQueue = [];
    var pendingConnects = [];
    var closeQueue = [];
    var pendingCloses = [];
    var sendQueue = [];
    var pendingSends = [];


    function $MockWebSocket(url) {

    }

    $MockWebSocket.prototype.send = function (msg) {
      pendingSends.push(msg);
    };

    $MockWebSocket.prototype.close = function () {
      pendingCloses.push(true);
    };


    this.createWebSocketBackend = function (url) {
      pendingConnects.push(url);

      return new $MockWebSocket(url);
    };

    this.flush = function () {
      var url, msg;
      while (url = pendingConnects.shift()) {
        var i = connectQueue.indexOf(url);
        if (i > -1) {
          connectQueue.splice(i, 1);
        }
      }

      while (pendingCloses.shift()) {
        closeQueue.shift();
      }

      while (msg = pendingSends.shift()) {
        var j;
        sendQueue.forEach(function(pending, i) {
          if (pending.message === msg.message) {
            j = i;
          }
        });

        if (j > -1) {
          sendQueue.splice(j, 1);
        }
      }
    };

    this.expectConnect = function (url) {
      connectQueue.push(url);
    };

    this.expectClose = function () {
      closeQueue.push(true);
    };

    this.expectSend = function (msg) {
      sendQueue.push(msg);
    };

    this.verifyNoOutstandingExpectation = function () {
      if (connectQueue.length || closeQueue.length || sendQueue.length) {
        throw new Error('Requests waiting to be flushed');
      }
    };

    this.verifyNoOutstandingRequest = function () {
      if (pendingConnects.length || pendingCloses.length || pendingSends.length) {
        throw new Error('Requests waiting to be processed');
      }
    };

  } // end $WebSocketBackend

  angular.module('ngWebSocketMock', [])
  .service('WebSocketBackend',  $WebSocketBackend)
  .service('$webSocketBackend', $WebSocketBackend);

  angular.module('angular-websocket-mock', ['ngWebSocketMock']);

}());<commit_msg>feat($MockWebSocket): protocols and ssl<commit_after>(function() {

  function $WebSocketBackend() {
    var connectQueue = [];
    var pendingConnects = [];
    var closeQueue = [];
    var pendingCloses = [];
    var sendQueue = [];
    var pendingSends = [];


    function $MockWebSocket(url, protocols) {
      this.protocols = protocols || 'Sec-WebSocket-Protocol';
      this.ssl = /(wss)/i.test(this.url);

    }

    $MockWebSocket.prototype.send = function (msg) {
      pendingSends.push(msg);
    };

    $MockWebSocket.prototype.close = function () {
      pendingCloses.push(true);
    };


    this.createWebSocketBackend = function (url, protocols) {
      pendingConnects.push(url);
      // pendingConnects.push({
      //   url: url,
      //   protocols: protocols
      // });

      if (protocols) {
        return new $MockWebSocket(url, protocols);
      }
      return new $MockWebSocket(url);
    };

    this.flush = function () {
      var url, msg, config;
      while (url = pendingConnects.shift()) {
        var i = connectQueue.indexOf(url);
        if (i > -1) {
          connectQueue.splice(i, 1);
        }
        // if (config && config.url) {
        // }
      }

      while (pendingCloses.shift()) {
        closeQueue.shift();
      }

      while (msg = pendingSends.shift()) {
        var j;
        sendQueue.forEach(function(pending, i) {
          if (pending.message === msg.message) {
            j = i;
          }
        });

        if (j > -1) {
          sendQueue.splice(j, 1);
        }
      }
    };

    this.expectConnect = function (url, protocols) {
      connectQueue.push(url);
      // connectQueue.push({url: url, protocols: protocols});
    };

    this.expectClose = function () {
      closeQueue.push(true);
    };

    this.expectSend = function (msg) {
      sendQueue.push(msg);
    };

    this.verifyNoOutstandingExpectation = function () {
      if (connectQueue.length || closeQueue.length || sendQueue.length) {
        throw new Error('Requests waiting to be flushed');
      }
    };

    this.verifyNoOutstandingRequest = function () {
      if (pendingConnects.length || pendingCloses.length || pendingSends.length) {
        throw new Error('Requests waiting to be processed');
      }
    };

  } // end $WebSocketBackend

  angular.module('ngWebSocketMock', [])
  .service('WebSocketBackend',  $WebSocketBackend)
  .service('$webSocketBackend', $WebSocketBackend);

  angular.module('angular-websocket-mock', ['ngWebSocketMock']);

}());
{'fraction_non_alphanumeric': 0.1430752453653217, 'fraction_numerical': 0.0017448200654307524, 'mean_word_length': 2.275714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7633655', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1360, 'n_words': 256}