🎉 Add missing wrap method on buffer abstraction

This commit is contained in:
Andrey Antukh 2025-08-12 10:30:02 +02:00
parent 3f71734cb4
commit 129d3e61fa

View File

@ -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))]