kriszyp / msgpackr

Ultra-fast MessagePack implementation with extension for record and structural cloning / msgpack.org[JavaScript/NodeJS]
MIT License
494 stars 55 forks source link

multiple Packr instances and useBuffer() #139

Open endel opened 5 months ago

endel commented 5 months ago

As the encoding Buffer is tied to the module scope (target), when using multiple Packr instances along with .useBuffer() - that Packr instance is not ensured to be using the correct Buffer.

A workaround would be to always call .useBuffer() prior to encoding, but that implies in creating a new DataView instance before each encode.

kriszyp commented 4 months ago

Last commit will cache the DataView (as is done elsewhere in the code), so you can performantly switch buffers back and forth with useBuffer() (without new DataView each time).