<commit_before>const io = require('socket.io-client');

function Server(address, _opts) {
  const opts = Object.assign({
    port: 8080,
  }, _opts);

  const socket = io(`http://${address}:${opts.port}`);

  const api = {
    queue(job, cb = null) {
      sendSocketEvent('job', {
        name: job.getName(),
        buffer: job.getBuffer()
      }, cb);
      return api;
    },
  };

  function sendSocketEvent(event, data, cb = null) {
    socket.connect();
    socket.emit(event, data, function (validation) {
      if (cb) {
        if (validation) cb(true);
        else cb(false);
      }
      socket.disconnect();
    });
  }

  return api;
}

module.exports = Server;<commit_msg>refactor server.js<commit_after>'use strict'

const io = require('socket.io-client')

function Server (address, _opts) {
  const opts = Object.assign({
    port: 8080
  }, _opts)

  const socket = io(`http://${address}:${opts.port}`)

  const api = {
    queue: (job, cb = null) => {
      sendSocketEvent('job', {
        name: job.getName(),
        buffer: job.getBuffer()
      }, cb)
      return api
    }
  }

  return api

  function sendSocketEvent (event, data, cb = null) {
    socket.connect()
    socket.emit(event, data, (validation) => {
      if (cb) {
        if (validation) cb(true)
        else cb(false)
      }
      socket.disconnect()
    })
  }
}

module.exports = Server

{'fraction_non_alphanumeric': 0.15922190201729106, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 2.4296296296296296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1308328', 'n_tokens_mistral': 465, 'n_tokens_neox': 450, 'n_words': 104}