msgpack.js icon indicating copy to clipboard operation
msgpack.js copied to clipboard

Web Worker support

Open futurist opened this issue 1 year ago • 3 comments

Want to use this lib in a WebWorker, but there's a line using window object, which is not exists in WebWorker.

futurist avatar May 28 '24 13:05 futurist

I would like to vote for this too. I am trying to use it in QuickJS but have the same issue.

 ./qjs -I msgpack.min.js 
ReferenceError: 'window' is not defined
    at <anonymous> (msgpack.min.js)
    at <eval> (msgpack.min.js)

slavslavov avatar Oct 05 '24 08:10 slavslavov

I know nothing about web workers, but you might need to adjust the end of the file, where it exports the functions, to your needs. Feel free to create a PR, although I'd need to accept it blindly because I'm not using web workers anywhere.

ygoe avatar Oct 06 '24 12:10 ygoe

I recently discovered this library (I started coding my own, because I wanted a lightweight simple object binary serializer/deserializer for a webapp, glad I discovered it before I started messing with arrays, which were giving me headaches already!). It does exactly what I needed, thank you :-)

I'm quite used to web workers I'll be doing a PR soon to solve this, it's trivial and it will increase the performance a lot, specially with big files.

marcrobledo avatar Apr 12 '25 11:04 marcrobledo