<commit_before>'use strict';

const { logEvent } = require('../log');
const { mapValues, omit, pSetTimeout } = require('../utilities');

// Create event when all protocol-specific servers have started
const emitStartEvent = async function ({
  protocols,
  schema,
  gracefulExit,
  measures,
}) {
  const message = 'Server is ready';
  const vars = getVars({ protocols, gracefulExit });
  const { duration } = measures.find(({ category }) => category === 'default');

  // Let other events finish first
  await pSetTimeout(0, { unref: false });

  await logEvent({
    event: 'start',
    phase: 'startup',
    message,
    vars,
    schema,
    duration,
  });
  return { startPayload: vars };
};

// Remove some properties from event payload as they are not serializable,
// or should not be made immutable
const getVars = function ({ protocols, gracefulExit }) {
  const protocolsA = mapValues(
    protocols,
    protocol => omit(protocol, ['server', 'protocolHandler']),
  );
  return { protocols: protocolsA, exit: gracefulExit };
};

module.exports = {
  emitStartEvent,
};<commit_msg>Rename variable<commit_after>'use strict';

const { logEvent } = require('../log');
const { mapValues, omit, pSetTimeout } = require('../utilities');

// Create event when all protocol-specific servers have started
const emitStartEvent = async function ({
  protocols,
  schema,
  gracefulExit,
  measures,
}) {
  const message = 'Server is ready';
  const vars = getEventVars({ protocols, gracefulExit });
  const { duration } = measures.find(({ category }) => category === 'default');

  // Let other events finish first
  await pSetTimeout(0, { unref: false });

  await logEvent({
    event: 'start',
    phase: 'startup',
    message,
    vars,
    schema,
    duration,
  });
  return { startPayload: vars };
};

// Remove some properties from event payload as they are not serializable,
// or should not be made immutable
const getEventVars = function ({ protocols, gracefulExit }) {
  const protocolsA = mapValues(
    protocols,
    protocol => omit(protocol, ['server', 'protocolHandler']),
  );
  return { protocols: protocolsA, exit: gracefulExit };
};

module.exports = {
  emitStartEvent,
};
{'fraction_non_alphanumeric': 0.13466787989080983, 'fraction_numerical': 0.0009099181073703367, 'mean_word_length': 3.7804347826086957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5794873', 'n_tokens_mistral': 641, 'n_tokens_neox': 626, 'n_words': 203}