         i)))
 
   (chars-to-str [_ string-buffer chars-length]
+    "Converts character codes to characters and appends them to a string buffer
+
+     string-buffer (StringBuffer) - Google String buffer to append characters to
+     chars-length (int) - The number of characters we are appending"
     (loop [i 0]
       (when (< i chars-length)
         (do
           (.append string-buffer (.fromCharCode js/String (aget read-codes i)))
           (recur (inc i))))))
 
-  (get-buffer [_] buffer)
+  (get-buffer [_]
+    "Gets the string buffer"
+    buffer)
 
   (read-utf8-chars [sr string-buffer offset length]
+    "Reads in a string buffer and appends the characters to a string
+
+     string-buffer (StringBuffer) Google string buffer we'll append characters to
+     offset (int) - Starting point to read the string buffer
+     length (int) - The number of bytes to read"
     (let [str-length (.bytes-to-codes sr offset length)]
       (.chars-to-str sr string-buffer str-length))))
 
 (defn make-string-reader []
+  "Convience method for making a string reader"
   (StringReader. (js/Uint8Array. 65536) (make-array 21846)))
 
 (def ^{:doc "Marker for the endianess of bytestreams"}

(ns longshi.fressian.utils
  "Utility data and functions for byte arrays")

(deftype StringWriter [code-pipe string-buffer]
  Object
  (string-to-codes [_ s start-pos end-pos]
    (loop [i 0 str-pos start-pos]
      (when (< str-pos end-pos)
        (do

          (recur (inc i) (inc str-pos))))))

 (write-str-bytes [_ str-length buf-length]
   "Writes out character codes to bytes

    str-length (int) - The length of the portion of the string we are reading
    buf-length (int) - The length of the buffer we are writing to"
   (loop [i 0 buf-pos 0]
     (let [code (aget code-pipe i)
           byte-size (cond (<= code 0x007f) 1 (> code 0x07ff) 3 :else 2)]
