cljs.repl/repl-read

functionsince v0.0-2719Edit
(repl-read request-prompt request-exit)
(repl-read request-prompt request-exit opts)

Source docstring:
Default :read hook for repl. Reads from *in* which must either be an
instance of LineNumberingPushbackReader or duplicate its behavior of both
supporting .unread and collapsing all of CR, LF, and CRLF into a single
\newline. repl-read:
  - skips whitespace, then
    - returns request-prompt on start of line, or
    - returns request-exit on end of stream, or
    - reads an object from the input stream, then
      - skips the next input character if it's end of line, then
      - returns the object.
Source code @ clojurescript:src/main/clojure/cljs/repl.cljc
(defn repl-read
  ([request-prompt request-exit]
   (repl-read request-prompt request-exit *repl-opts*))
  ([request-prompt request-exit opts]
   (let [current-in *in*
         bind-in?   (true? (:source-map-inline opts))]
     (binding [*in* (if bind-in?
                      ((:reader opts))
                      *in*)]
       (or ({:line-start request-prompt :stream-end request-exit}
             (skip-whitespace *in*))
         (let [input (reader/read {:read-cond :allow :features #{:cljs}} *in*)]
           ;; Transfer 1-char buffer to original *in*
           (readers/unread current-in (readers/read-char *in*))
           (skip-if-eol (if bind-in? current-in *in*))
           input))))))