<commit_before>const typeforce = require('typeforce')

// compose :: addProps -> (state -> buffer -> [state, buffer])
const compose = args => (state, buffer) => {
  typeforce(typeforce.Array, args)
  typeforce(typeforce.Object, state)
  typeforce(typeforce.Buffer, buffer)
  args.reduce(([state, buffer], f) => f(state, buffer), [state, buffer])
  return [state, buffer]
}

// addProp :: propName -> f -> (state -> buffer -> [state, buffer])
const addProp = (propName, f) => (state, buffer) => {
  typeforce(typeforce.String, propName)
  typeforce(typeforce.Function, f)
  typeforce(typeforce.Object, state)
  typeforce(typeforce.Buffer, buffer)
  const [res, bufferLeft] = f(buffer)
  state[propName] = res
  return [state, bufferLeft]
}

module.exports = {
  compose,
  addProp
}<commit_msg>fixed bug in compose<commit_after>const typeforce = require('typeforce')

// compose :: addProps -> (state -> buffer -> [state, buffer])
const compose = args => (state, buffer) => {
  typeforce(typeforce.Array, args)
  typeforce(typeforce.Object, state)
  typeforce(typeforce.Buffer, buffer)
  return args.reduce(([state, buffer], f) => f(state, buffer), [state, buffer])
}

// addProp :: propName -> f -> (state -> buffer -> [state, buffer])
const addProp = (propName, f) => (state, buffer) => {
  typeforce(typeforce.String, propName)
  typeforce(typeforce.Function, f)
  typeforce(typeforce.Object, state)
  typeforce(typeforce.Buffer, buffer)
  const [res, bufferLeft] = f(buffer)
  state[propName] = res
  return [state, bufferLeft]
}

module.exports = {
  compose,
  addProp
}
{'fraction_non_alphanumeric': 0.1619047619047619, 'fraction_numerical': 0.0, 'mean_word_length': 4.588652482269503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3253497', 'n_tokens_mistral': 522, 'n_tokens_neox': 515, 'n_words': 127}