diff --git a/common/src/app/common/buffer.cljc b/common/src/app/common/buffer.cljc index 69413db7db..226e547b45 100644 --- a/common/src/app/common/buffer.cljc +++ b/common/src/app/common/buffer.cljc @@ -127,6 +127,18 @@ (finally (.order ~target ByteOrder/LITTLE_ENDIAN)))))) +(defn wrap + [data] + #?(:clj (let [buffer (ByteBuffer/wrap ^bytes data)] + (.order buffer ByteOrder/LITTLE_ENDIAN)) + :cljs + (cond + (instance? js/Uint8Array data) + (new js/DataView (.-buffer ^js data)) + + :else + (throw (js/Error. "unexpected type"))))) + (defn allocate [size] #?(:clj (let [buffer (ByteBuffer/allocate (int size))]