An elegant library for working with IO in Clojure.
Pipes are functions that take a source and a sink and may or may not return a result.
(require '[io.github.rutledgepaulv.io.pipes :as pipes])
(def pipeline
(pipes/chain
; only match lines that contain the word "dog"
(pipes/grep #"dog")
; only take the first 5 matches
(pipes/head 5)
; replace the word "dog" with "cat"
(pipes/sed #"dog" "cat")
; compute a hash of the content before gzipping
pipes/sha256
; gzip the data
pipes/gzip))
(pipeline (io/file "input.txt") (io/file "output.txt"))
; results of each pipe are returned positionally when using chain
; (nil nil nil #object["[B" 0x49828df7 "[B@49828df7"] nil)