<commit_before>Flow.Coffeescript = (_, guid, sandbox) ->
  _kernel = Flow.CoffeescriptKernel

  print = (arg) ->
    if arg isnt print
      sandbox.results[guid].outputs arg
    print

  isRoutine = (f) ->
    for name, routine of sandbox.routines when f is routine
      return yes
    return no

  # XXX special-case functions so that bodies are not printed with the raw renderer.
  render = (input, output) ->
    sandbox.results[guid] = sandboxResult =
      result: signal null
      outputs: outputBuffer = Flow.Async.createBuffer []
    
    evaluate = (ft) ->
      if ft?.isFuture
        ft (error, result) ->
          if error
            output.error Flow.Exception 'Error evaluating cell', error
          else
            if ft.render
              ft.render result, (error, result) ->
                if error
                  output.error Flow.Exception 'Error rendering output', error
                else
                  output.data result 
            else
              #XXX pick smarter renderers based on content
              output.data Flow.ObjectBrowser 'output', ft
      else
        output.data Flow.ObjectBrowser 'output', ft

    outputBuffer.subscribe evaluate

    tasks = [
      _kernel.safetyWrapCoffeescript guid
      _kernel.compileCoffeescript
      _kernel.parseJavascript
      _kernel.createRootScope sandbox
      _kernel.removeHoistedDeclarations
      _kernel.rewriteJavascript sandbox
      _kernel.generateJavascript
      _kernel.compileJavascript
      _kernel.executeJavascript sandbox, print
    ]
    (Flow.Async.pipe tasks) input, (error) ->
      output.error error if error
      output.end()

      cellResult = sandboxResult.result()
      if cellResult
        if isFunction cellResult
          if isRoutine cellResult
            print cellResult()
          else
            evaluate cellResult
        else
          output.close Flow.ObjectBrowser 'result', cellResult

  render.isCode = yes
  render
<commit_msg>Always display outputs from cells<commit_after>Flow.Coffeescript = (_, guid, sandbox) ->
  _kernel = Flow.CoffeescriptKernel

  print = (arg) ->
    if arg isnt print
      sandbox.results[guid].outputs arg
    print

  isRoutine = (f) ->
    for name, routine of sandbox.routines when f is routine
      return yes
    return no

  # XXX special-case functions so that bodies are not printed with the raw renderer.
  render = (input, output) ->
    sandbox.results[guid] = cellResult =
      result: signal null
      outputs: outputBuffer = Flow.Async.createBuffer []
    
    evaluate = (ft) ->
      if ft?.isFuture
        ft (error, result) ->
          if error
            output.error Flow.Exception 'Error evaluating cell', error
          else
            if ft.render
              ft.render result, (error, result) ->
                if error
                  output.error Flow.Exception 'Error rendering output', error
                else
                  output.data result 
            else
              #XXX pick smarter renderers based on content
              output.data Flow.ObjectBrowser 'output', ft
      else
        output.data Flow.ObjectBrowser 'output', ft

    outputBuffer.subscribe evaluate

    tasks = [
      _kernel.safetyWrapCoffeescript guid
      _kernel.compileCoffeescript
      _kernel.parseJavascript
      _kernel.createRootScope sandbox
      _kernel.removeHoistedDeclarations
      _kernel.rewriteJavascript sandbox
      _kernel.generateJavascript
      _kernel.compileJavascript
      _kernel.executeJavascript sandbox, print
    ]
    (Flow.Async.pipe tasks) input, (error) ->
      output.error error if error
      output.end()

      result = cellResult.result()
      if isFunction result
        if isRoutine result
          print result()
        else
          evaluate result
      else
        output.close Flow.ObjectBrowser 'result', result

  render.isCode = yes
  render

{'fraction_non_alphanumeric': 0.0673469387755102, 'fraction_numerical': 0.0, 'mean_word_length': 2.0184757505773674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '658959', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1009, 'n_words': 306}