<commit_before>class RunnerClient {
  constructor() {
    this.port = 3001
    this.ws = new WebSocket(`ws://localhost:${this.port}`)
    this.router = {
      'run:start:ack': () => this.startRun(),
      'run:end:ack': () => this.runNext()
    }
    this.runs = []

    this.ws.onopen = () => {
      this.ws.onmessage = ({ data }) => this.onMessage(JSON.parse(data))
      this.send('file:start')
      this.runNext()
    }
  }

  enqueueRun(title, fn) {
    this.runs.push({ title, fn })
  }

  runNext() {
    this.currentRun = this.runs.shift()

    if (this.currentRun) {
      this.send('run:start', this.currentRun)
    }
    else {
      this.send('file:end')
    }
  }

  startRun() {
    try {
      const res = this.currentRun.fn()<commit_msg>:nut_and_bolt: (runner-client) close connexion on file end<commit_after>class RunnerClient {
  constructor() {
    this.port = 3001
    this.ws = new WebSocket(`ws://localhost:${this.port}`)
    this.router = {
      'run:start:ack': () => this.startRun(),
      'run:end:ack': () => this.runNext()
    }
    this.runs = []

    this.ws.onopen = () => {
      this.ws.onmessage = ({ data }) => this.onMessage(JSON.parse(data))
      this.send('file:start')
      this.runNext()
    }
  }

  enqueueRun(title, fn) {
    this.runs.push({ title, fn })
  }

  runNext() {
    this.currentRun = this.runs.shift()

    if (this.currentRun) {
      this.send('run:start', this.currentRun)
    }
    else {
      this.send('file:end')
      this.ws.close()
    }
  }

  startRun() {
    try {
      const res = this.currentRun.fn()
{'fraction_non_alphanumeric': 0.18556048131728942, 'fraction_numerical': 0.00506649778340722, 'mean_word_length': 2.3832976445396143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4768073', 'n_tokens_mistral': 587, 'n_tokens_neox': 569, 'n_words': 84}