       bos))
   (write-double! [bos d]
     (do
-      (case d
-        0.0 (bsp/write! bos (.-DOUBLE_0 c/codes))
-        1.0 (bsp/write! bos (.-DOUBLE_1 c/codes))
+      (cond
+        (== d 0.0) (bsp/write! bos (.-DOUBLE_0 c/codes))
+        (== d 1.0) (bsp/write! bos (.-DOUBLE_1 c/codes))
+        :else
         (do
           (bsp/write! bos (.-DOUBLE c/codes))
           (bsp/write-double! bos d)))

  [dest source offset length]
  (loop [pos offset]
    (when-let [ch (aget source pos)]
      (case (bit-shift-right ch 4)
        (0 1 2 3 4 5 6 7)
        (do
          (.append dest (.fromCharCode js/String ch))
          (recur (inc pos)))
        (12 13)
        (let [ch1 (aget source (inc pos))]
          (do
            (.append
              dest
              (.fromCharCode
                js/String
                (bit-or (bit-and ch1 0x3f) (bit-shift-left (bit-and ch 0x1f) 6))))
            (recur (+ 2 pos))))
        (14)
        (let [ch1 (aget source (inc pos))
              ch2 (aget source (+ 2 pos))]
          (do
            (.append
              dest
              (.fromCharCode
                js/String
                (bit-or
                  (bit-and ch2 0x3f)
                  (bit-shift-left (bit-and ch1 0x3f) 6)
                  (bit-shift-left (bit-and ch 0x0f) 12))))
            (recur (+ 3 pos))))
        (throw (js/Error. (str "Invalid UTF Character (" ch ")")))))))

(defn read-string-buffer!
  "Reads a string from a byte array

                          :else 2)]
      (if (and (< str-pos (alength s)) (<= (+ buf-pos ch-enc-size) (alength buffer)))
        (do
          (cond
            (== ch-enc-size 1) (aset buffer buf-pos ch)
            (== ch-enc-size 2) (do
                (aset buffer buf-pos (bit-or (bit-and (bit-shift-right ch 6) 0x1f) 0xc0))
                (aset buffer (inc buf-pos) (bit-or (bit-and (bit-shift-right ch 0) 0x3f) 0x80)))
            (== ch-enc-size 3) (do
                (aset buffer buf-pos (bit-or (bit-and (bit-shift-right ch 12) 0x0f) 0xe0))
                (aset buffer (inc buf-pos) (bit-or (bit-and (bit-shift-right ch 6) 0x3f) 0x80))
                (aset buffer (+ 2 buf-pos) (bit-or (bit-and (bit-shift-right ch 0) 0x3f) 0x80))))
