edi9999 / jsqrcode

[deprecated] Lazarsoft's jsqrcode as a node module, object oriented, and with tests
Apache License 2.0
280 stars 63 forks source link

Decode in a web worker #10

Closed TCMiranda closed 8 years ago

TCMiranda commented 8 years ago

Hello!

Just wondering if there is some way to run the library in a web worker.

The current implementation fails after trying to create DOM elements to work with, maybe there is a way to skip this and allow the raw data to be posted to a worker.

Thoughts?

Thanks!

TCMiranda commented 8 years ago

Ah ok, it is possible, but not documented!

We can:

const data = context.getImageData(0, 0, width, height);

decoder.postMessage({ widht: data.width, height: data.height }, data.data);

We should add it to the usage docs, since increases the site responsibility a lot!!

But that kind of request is a little broken, and the .decode method is not returning errors to the callback.

But one thing is true, that is an amazing library, and the hard work is done, we should work to upgrade that api for more usability, right?

Thanks!

PS. I am keeping this open, to notify that this is acctually broken!

TCMiranda commented 8 years ago

11