From 129d3e61faaf5cf94255a7fbe07d0c217b37cad2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 12 Aug 2025 10:30:02 +0200 Subject: [PATCH] :tada: Add missing wrap method on buffer abstraction --- common/src/app/common/buffer.cljc | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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))]