<commit_before>require! {
  fs
  tar
  zlib.create-gunzip
  events.EventEmitter
}
{ next, add-extension } = require './utils'

module.exports = list = (options) ->
  { path, gzip } = options |> apply
  emitter = new EventEmitter
  ended = no
  error = no
  files = []

  on-error = (err) ->
    error := err
    err |> emitter.emit 'error', _

  on-end = ->
    ended := yes
    files |> emitter.emit 'end', _

  on-entry = (entry) ->
    entry |> files.push
    entry |> emitter.emit 'entry', _

  on-listener = (name, fn) ->
    switch name
      case 'error' then error |> fn if error
      case 'end' then files |> fn if ended
<commit_msg>refactor(list): livescript-like switch control strcuture<commit_after>require! {
  fs
  tar
  zlib.create-gunzip
  events.EventEmitter
}
{ next, add-extension } = require './utils'

module.exports = list = (options) ->
  { path, gzip } = options |> apply
  emitter = new EventEmitter
  ended = no
  error = no
  files = []

  on-error = (err) ->
    error := err
    err |> emitter.emit 'error', _

  on-end = ->
    ended := yes
    files |> emitter.emit 'end', _

  on-entry = (entry) ->
    entry |> files.push
    entry |> emitter.emit 'entry', _

  on-listener = (name, fn) ->
    switch name
    | 'error'=> error |> fn if error
    | 'end' => files |> fn if ended

{'fraction_non_alphanumeric': 0.1491628614916286, 'fraction_numerical': 0.0, 'mean_word_length': 2.4514435695538057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2036519', 'n_tokens_mistral': 465, 'n_tokens_neox': 452, 'n_words': 126}