<commit_before>/**
 * This module contains some common helpers shared between middlewares
 */
'use strict'

const mime = require('mime')
const _ = require('lodash')
const parseRange = require('range-parser')
const Buffer = require('safe-buffer').Buffer

const log = require('../logger').create('web-server')

class PromiseContainer {
  constructor () {
    this.promise = null
  }

  then (success, error) {
    error = error || _.noop
    return this.promise.then(success).catch(error)
  }

  set (newPromise) {
    this.promise = newPromise
  }
}

function serve404 (response, path) {
  log.warn('404: ' + path)
  response.writeHead(404)
  return response.end('NOT FOUND')
}
<commit_msg>fix(middleware): Obey the Promise API.<commit_after>/**
 * This module contains some common helpers shared between middlewares
 */
'use strict'

const mime = require('mime')
const _ = require('lodash')
const parseRange = require('range-parser')
const Buffer = require('safe-buffer').Buffer

const log = require('../logger').create('web-server')

class PromiseContainer {
  constructor () {
    this.promise = null
  }

  then (success, error) {
    return this.promise.then(success, error)
  }

  set (newPromise) {
    this.promise = newPromise
  }
}

function serve404 (response, path) {
  log.warn('404: ' + path)
  response.writeHead(404)
  return response.end('NOT FOUND')
}

{'fraction_non_alphanumeric': 0.14170927684441198, 'fraction_numerical': 0.013148283418553688, 'mean_word_length': 4.0, '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': '5076086', 'n_tokens_mistral': 447, 'n_tokens_neox': 425, 'n_words': 108}