<commit_before>'use strict';
/*globals SockJS*/

/**
 * Minimum viable SockJS client. This function is stringified and written in
 * to our client side library.
 *
 * @runat client
 * @api private
 */
module.exports = function client() {
  var primus = this
    , socket;

  //
  // Selects an available Engine.IO factory.
  //
  var Factory = (function Factory() {
    if ('undefined' !== typeof SockJS) return SockJS;

    try { return Primus.require('sockjs-client-node'); }
    catch (e) {}

    return undefined;
  })();

  if (!Factory) return primus.critical(new Error('Missing required `sockjs-client-node` module. Please run `npm install --save sockjs-client-node`'));

  //
  // Connect to the given URL.
  //
  primus.on('outgoing::open', function opening() {
    if (socket) socket.close();

    primus.socket = socket = new Factory(primus.uri({ protocol: 'http' }), null, {
      websocket: !primus.AVOID_WEBSOCKETS
    });

    //
    // Setup the Event handlers.
    //
    socket.onopen = primus.emits('open');
    socket.onerror = primus.emits('error');
    socket.onclose = function (e) {
      var event = e && e.code === 1002 ? 'error' : 'end';

      //
      // The timeout replicates the behaviour of primus.emits so we're not
      // affected by any timing bugs.
      //
      setTimeout(function timeout() {
        primus.emit('incoming::'+ event, e);
      }, 0);
    };
    socket.onmessage = primus.emits('data', function parse(evt) {
      return evt.data;
    });
  });

  //<commit_msg>[fix] Correctly disable websockets for SockJS<commit_after>'use strict';
/*globals SockJS*/

/**
 * Minimum viable SockJS client. This function is stringified and written in
 * to our client side library.
 *
 * @runat client
 * @api private
 */
module.exports = function client() {
  var primus = this
    , socket;

  //
  // Selects an available Engine.IO factory.
  //
  var Factory = (function Factory() {
    if ('undefined' !== typeof SockJS) return SockJS;

    try { return Primus.require('sockjs-client-node'); }
    catch (e) {}

    return undefined;
  })();

  if (!Factory) return primus.critical(new Error('Missing required `sockjs-client-node` module. Please run `npm install --save sockjs-client-node`'));

  //
  // Connect to the given URL.
  //
  primus.on('outgoing::open', function opening() {
    if (socket) socket.close();

    primus.socket = socket = new Factory(primus.uri({ protocol: 'http' }), null, {
      info: {
        websocket: !primus.AVOID_WEBSOCKETS
      }
    });

    //
    // Setup the Event handlers.
    //
    socket.onopen = primus.emits('open');
    socket.onerror = primus.emits('error');
    socket.onclose = function (e) {
      var event = e && e.code === 1002 ? 'error' : 'end';

      //
      // The timeout replicates the behaviour of primus.emits so we're not
      // affected by any timing bugs.
      //
      setTimeout(function timeout() {
        primus.emit('incoming::'+ event, e);
      }, 0);
    };
    socket.onmessage = primus.emits('data', function parse(evt) {
      return evt.data;
    });
  });

  //
{'fraction_non_alphanumeric': 0.1514857881136951, 'fraction_numerical': 0.003229974160206718, 'mean_word_length': 2.555683122847302, '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': '7124346', 'n_tokens_mistral': 1001, 'n_tokens_neox': 962, 'n_words': 270}