@@ -78,21 +78,19 @@ Value convertMPToJSI(Runtime &runtime, msgpack::object &o) {
7878 case msgpack::type::BIN: {
7979 auto ptr = o.via .bin .ptr ;
8080 int size = o.via .bin .size ;
81- // make ArrayBuffer and copy in data
82- Function arrayBufferCtor =
83- runtime.global ().getPropertyAsFunction (runtime, " ArrayBuffer" );
84- Value ab = arrayBufferCtor.callAsConstructor (runtime, size);
85- Object abo = ab.getObject (runtime);
86- ArrayBuffer abbuf = abo.getArrayBuffer (runtime);
87- std::copy (ptr, ptr + size, abbuf.data (runtime));
88-
89- // Wrap in Buffer like framed-msg-pack
90- Object bufObj = runtime.global ().getPropertyAsObject (runtime, " Buffer" );
91- Function bufFrom = bufObj.getPropertyAsFunction (runtime, " from" );
92- Value buf = bufFrom.callWithThis (
93- runtime, bufObj,
94- std::move (ab)); // Buffer shares the memory and just wraps
95- return buf;
81+
82+ // make ArrayBuffer and copy in data
83+ Function arrayBufferCtor =
84+ runtime.global ().getPropertyAsFunction (runtime, " ArrayBuffer" );
85+ Value ab = arrayBufferCtor.callAsConstructor (runtime, size);
86+ Object abo = ab.getObject (runtime);
87+ ArrayBuffer abbuf = abo.getArrayBuffer (runtime);
88+ std::copy (ptr, ptr + size, abbuf.data (runtime));
89+
90+ // Wrap in Uint8Array
91+ Function uCtor = runtime.global ().getPropertyAsFunction (runtime, " Uint8Array" );
92+ Value uc = uCtor.callAsConstructor (runtime, std::move (abbuf));
93+ return uc;
9694 }
9795 case msgpack::type::ARRAY: {
9896 auto size = o.via .array .size ;
0 commit comments