<commit_before>const { Transform } = require('stream')
// const log = require('../log')

module.exports = function(transform, callback) {
  return new Transform({
    readableObjectMode: true,
    writableObjectMode: true,
    transform
    // transform: function(object, encoding, callback) {
    //   try {
    //     transform(object, encoding, callback)
    //   }
    //   catch(err) {
    //     log.error(err)
    //     throw err
    //   }
    // }

  }).on('finish', callback)
}<commit_msg>Adding better exception handling<commit_after>const { Transform } = require('stream')

module.exports = function(transform, callback) {
  return new Transform({
    readableObjectMode: true,
    writableObjectMode: true,
    transform
  }).on('finish', callback)
}
{'fraction_non_alphanumeric': 0.14397905759162305, 'fraction_numerical': 0.0, 'mean_word_length': 2.883248730964467, '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': '6578700', 'n_tokens_mistral': 227, 'n_tokens_neox': 217, 'n_words': 50}