   ^mikron.runtime.buffer.IMikronByteBuffer [^Buffer buffer]
   (.-byte-buffer buffer))
 
-(defn get-bit-pos
+(defn get-bit-position
   "Gets the bit position of `buffer`."
-  #?(:clj {:inline (fn [buffer] `(get-bit-pos* (get-bit-buffer ~buffer)))})
-  ^long [^Buffer buffer]
-  (get-bit-pos* (get-bit-buffer buffer)))
-
-(defn set-bit-pos
+  #?(:clj {:inline (fn [buffer] `(get-bit-position* (get-bit-buffer ~buffer)))})
+  ^long [^Buffer buffer]
+  (get-bit-position* (get-bit-buffer buffer)))
+
+(defn set-bit-position
   "Sets the bit position of `buffer` to `value`."
-  #?(:clj {:inline (fn [buffer value] `(set-bit-pos* (get-bit-buffer ~buffer) ~value))})
-  [^Buffer buffer ^long value]
-  (set-bit-pos* (get-bit-buffer buffer) value))
+  #?(:clj {:inline (fn [buffer value] `(set-bit-position* (get-bit-buffer ~buffer) ~value))})
+  [^Buffer buffer ^long value]
+  (set-bit-position* (get-bit-buffer buffer) value))
 
 (defn get-bit-index
   "Gets the bit index of `buffer`."

(deftype MikronByteBuffer
  #?(:clj  [^ByteBuffer buffer]
     :cljs [^NativeJsBuffer buffer
            ^long ^:unsynchronized-mutable pos
            ^boolean ^:unsynchronized-mutable le])
  IMikronByteBuffer
  (take-byte* [_]
    #?(:clj  (unchecked-long (.get buffer))
       :cljs (with-delta pos 1 (.readInt8 buffer pos true))))
  (put-byte* [_ value]
    #?(:clj  (.put buffer (unchecked-byte value))
       :cljs (with-delta pos 1 (.writeInt8 buffer value pos true))))

  (take-short* [_]
    #?(:clj  (unchecked-long (.getShort buffer))
       :cljs (with-delta pos 2 (with-le le (.readInt16 buffer pos true)))))
  (put-short* [_ value]
    #?(:clj  (.putShort buffer (unchecked-short value))
       :cljs (with-delta pos 2 (with-le le (.writeInt16 buffer value pos true)))))

  (take-int* [_]
    #?(:clj  (.getInt buffer)
       :cljs (with-delta pos 4 (with-le le (.readInt32 buffer pos true)))))
  (put-int* [_ value]
    #?(:clj  (.putInt buffer (unchecked-int value))
       :cljs (with-delta pos 4 (with-le le (.writeInt32 buffer value pos true)))))

  (take-long* [this]
    #?(:clj  (.getLong buffer)


(deftype MikronBitBuffer [^long ^:unsynchronized-mutable value
                          ^long ^:unsynchronized-mutable index
                          ^long ^:unsynchronized-mutable position]
  IMikronBitBuffer
  (get-bit-position* [_]
    position)
  (set-bit-position* [_ value']
    (set! position (unchecked-long value')) nil)

  (get-bit-index* [_]
    index)
