How do I use the library?

Created by Stephen Compall
Keywords:
README usage

After requiring the module [com.nocandysw.stream-stream], your key entry point is `[read-block-seq]', which transforms an input-stream or reader into a lazy sequence of byte or char arrays. You can process this as-is, or reinterpret it as an efficiently chunked Clojure seq with `[block-seq->seq]'.

For symmetry, there is `[write-block-seq]', which writes a sequence of byte or char arrays to an output stream or writer, respectively.

`block-seq->seq' is interesting all on its own; it works on any seqable of seqables, and maintains the laziness of `concat' on infinite inputs, so `(block-seq->seq xs)' can be used as a extra-chunking version of `(apply concat xs)'.

Extension beyond the realm of `java.io' is an exercise for you; you can extend these functions by way of the `[readable-contents]' and `[writable-contents]' protocols.

Also interesting is `[->char-array-seq-sequence]', which takes what `read-block-seq' might return for a reader and puts a `java.lang.CharSequence' façade on it, without forcing the whole thing. Of course, if you pass it an infinite stream, `count' will never return on it…