class Closure::Compiler

def compile(io)

block, for streaming.
JavaScript as a string or yields an IO object containing the response to a
Can compile a JavaScript string or open IO object. Returns the compiled
def compile(io)
  result, error = nil, nil
  status = Closure::Popen.popen(command) do |stdin, stdout, stderr|
    if io.respond_to? :read
      while buffer = io.read(4096) do
        stdin.write(buffer)
      end
    else
      stdin.write(io.to_s)
    end
    stdin.close
    if Closure::Popen::WINDOWS
      stderr.close
      result = stdout.read
      error = "Stderr cannot be read on Windows."
    else
      out_thread = Thread.new { result = stdout.read }
      err_thread = Thread.new { error  = stderr.read }
      out_thread.join and err_thread.join
    end
    yield(StringIO.new(result)) if block_given?
  end
  raise Error, error unless status.success?
  result
end