Liking cljdoc? Tell your friends :D

std.block.reader


createclj

(create string)

create reader from string

(type (create "hello world")) => clojure.tools.reader.reader_types.IndexingPushbackReader

create reader from string

(type (create "hello world"))
=> clojure.tools.reader.reader_types.IndexingPushbackReader
raw docstring

ignore-charclj

(ignore-char reader)

returns nil and moves reader one char forward

(->> ignore-char (read-repeatedly (create "abc")) (take 3) (apply str)) => ""

returns nil and moves reader one char forward

(->> ignore-char
     (read-repeatedly (create "abc"))
     (take 3)
     (apply str))
=> ""
raw docstring

peek-charclj

(peek-char reader)

returns the current reader char with moving

(->> (read-times (create "abc") peek-char 3) (apply str)) => "aaa"

returns the current reader char with moving

(->> (read-times (create "abc")
                 peek-char
                 3)
     (apply str))
=> "aaa"
raw docstring

read-charclj

(read-char reader)

reads single char and move forward

(->> read-char (read-repeatedly (create "abc")) (take 3) (apply str)) => "abc"

reads single char and move forward

(->> read-char
     (read-repeatedly (create "abc"))
     (take 3)
     (apply str))
=> "abc"
raw docstring

read-includeclj

(read-include reader read-fn)
(read-include reader read-fn stop-fn)

reads up to a given predicate

(read-include (create " a") read-char (complement check/voidspace?)) => [[\space \space] \a]

reads up to a given predicate

(read-include (create "  a")
              read-char (complement check/voidspace?))
=> [[\space \space] \a]
raw docstring

read-repeatedlyclj

(read-repeatedly reader read-fn)
(read-repeatedly reader read-fn stop-fn)

reads input repeatedly

(->> (read-repeatedly (create "abcdefg") #(str (read-char %) (read-char %)) empty?) (take 5)) => ["ab" "cd" "ef" "g"]

reads input repeatedly

(->> (read-repeatedly (create "abcdefg")
                      #(str (read-char %) (read-char %))
                      empty?)
     (take 5))
=> ["ab" "cd" "ef" "g"]
raw docstring

read-timesclj

(read-times reader read-fn n)

reads input repeatedly

(->> (read-times (create "abcdefg") #(str (read-char %) (read-char %)) 2)) => ["ab" "cd"]

reads input repeatedly

(->> (read-times (create "abcdefg")
                 #(str (read-char %) (read-char %))
                 2))
=> ["ab" "cd"]
raw docstring

read-to-boundaryclj

(read-to-boundary reader)
(read-to-boundary reader allowed)

reads to an input boundary

(read-to-boundary (create "abc efg")) => "abc"

reads to an input boundary

(read-to-boundary (create "abc efg"))
=> "abc"
raw docstring

read-untilclj

(read-until reader pred)

reads inputs until the predicate is reached

(read-until (create "abcde") (fn [ch] (= (str ch) "d"))) => "abc"

reads inputs until the predicate is reached

(read-until (create "abcde")
            (fn [ch]
              (= (str ch) "d")))
=> "abc"
raw docstring

read-whileclj

(read-while reader pred & [eof?])

reads input while the predicate is true

(read-while (create "abcde") (fn [ch] (not= (str ch) "d"))) => "abc"

reads input while the predicate is true

(read-while (create "abcde")
            (fn [ch]
              (not= (str ch) "d")))
=> "abc"
raw docstring

reader-positionclj

(reader-position reader)

returns the position of the reader

(-> (create "abc") step-char step-char reader-position) => [1 3]

returns the position of the reader

(-> (create "abc")
    step-char
    step-char
    reader-position)
=> [1 3]
raw docstring

slurpclj

(slurp reader)

reads rest of input from reader

(reader/slurp (reader/step-char (create "abc efg"))) => "bc efg"

reads rest of input from reader

(reader/slurp (reader/step-char (create "abc efg")))
=> "bc efg"
raw docstring

step-charclj

(step-char reader)

moves reader one char forward

(-> (create "abc") step-char read-char str) => "b"

moves reader one char forward

(-> (create "abc")
    step-char
    read-char
    str)
=> "b"
raw docstring

throw-readerclj

(throw-reader reader message & input)

throws a reader message

(throw-reader (create "abc") "Message" {:data true}) => (throws)

throws a reader message

(throw-reader (create "abc")
              "Message"
              {:data true})
=> (throws)
raw docstring

unread-charclj

(unread-char reader ch)

move reader one char back, along with char

(-> (create "abc") (step-char) (unread-char \A) (reader/slurp)) => "Abc"

move reader one char back, along with char

(-> (create "abc")
    (step-char)
    (unread-char \A)
    (reader/slurp))
=> "Abc"
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close