rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

Does async work with Electron apps? #13

Closed Luiz-N closed 7 years ago

Luiz-N commented 7 years ago

I know web workers aren't natively supported for electron apps like atom (where i'm trying to use this) so i was wondering how the async call works in node applications.. forking under the hood or..?

rotemdan commented 7 years ago

The async functionality doesn't create forked Node processes. I believe that when no web worker support is available it currently falls back to processing small chunks of data at a time and yielding to the event loop after some interval has elapsed (I believe around 20ms).

In principle I can't see any reason not to have support for forked processes as well, but this doesn't seem like something I'd have time for in the foreseeable future. There might be some polyfills/shims that could help though (WebWorker shim for node?), though I can't guarantee they would work correctly.

Also, in general maintaining the async mode turned out to be quite difficult (testing, documenting, correct error handling etc.) and in retrospect it might have been better to make the core library as light and simple as possible and perhaps split the async functionality into a different, higher level library. When/if that happens I might consider adding this functionality as well.

Luiz-N commented 7 years ago

Thanks for the thorough response! I'll probably just handle forking manually for now