Last active
January 20, 2021 01:18
-
-
Save phenomnomnominal/57816f173591a3914e50b40cb21bd4ae to your computer and use it in GitHub Desktop.
workerRequire example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEFORE: | |
const { somethingCPUIntensive } = require('./cpu-intensive'); | |
somethingCPUIntensive(); // run synchronously blocking the main thread | |
// AFTER: | |
const { somethingCPUIntensive } = workerRequire('./cpu-intensive'); | |
await somethingCPUIntensive(); // run asynchronously in a worker thread |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment