<commit_before>const createHtml = require('create-html')
const xtend = require('xtend')
const stringToStream = require('string-to-stream')

module.exports = html

// create html stream
// obj -> obj? -> (req, res) -> rstream
function html (state) {
  return function initHtml (opts) {
    opts = opts || {}
    const defaultOpts = {
      entry: 'bundle.js',
      css: 'bundle.css',
      meta: '<meta name="viewport" content="width=device-width, initial-scale=1">'
    }
    const htmlOpts = xtend(defaultOpts, opts)
    state.htmlOpts = htmlOpts
    const html = createHtmlCompat(htmlOpts)

    return function htmlHandler (req, res) {
      if (res) res.setHeader('Content-Type', 'text/html')
      return stringToStream(html)
    }
  }
}

// v3.0 uses --html.entry, but create-html expects `script`
function createHtmlCompat (opts) {
  const optsCopy = xtend(opts)
  optsCopy.script = optsCopy.entry
  return createHtml(optsCopy)
}<commit_msg>correct default opts<commit_after>const createHtml = require('create-html')
const xtend = require('xtend')
const stringToStream = require('string-to-stream')

module.exports = html

// create html stream
// obj -> obj? -> (req, res) -> rstream
function html (state) {
  return function initHtml (opts) {
    opts = opts || {}
    const defaultOpts = {
      entry: 'bundle.js',
      css: 'bundle.css',
      head: '<meta name="viewport" content="width=device-width, initial-scale=1">'
    }
    const htmlOpts = xtend(defaultOpts, opts)
    state.htmlOpts = htmlOpts
    const html = createHtmlCompat(htmlOpts)

    return function htmlHandler (req, res) {
      if (res) res.setHeader('Content-Type', 'text/html')
      return stringToStream(html)
    }
  }
}

// v3.0 uses --html.entry, but create-html expects `script`
function createHtmlCompat (opts) {
  const optsCopy = xtend(opts)
  optsCopy.script = optsCopy.entry
  return createHtml(optsCopy)
}
{'fraction_non_alphanumeric': 0.13557540725170783, 'fraction_numerical': 0.0031529164477141357, 'mean_word_length': 3.544152744630072, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7437636', 'n_tokens_mistral': 601, 'n_tokens_neox': 609, 'n_words': 154}