mirror of
https://github.com/penpot/penpot.git
synced 2026-04-26 11:48:28 +00:00
🎉 Add missing wrap method on buffer abstraction
This commit is contained in:
parent
3f71734cb4
commit
129d3e61fa
@ -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))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user