Skip to content

Instantly share code, notes, and snippets.

@phenomnomnominal
Last active January 20, 2021 01:18
Show Gist options
  • Save phenomnomnominal/57816f173591a3914e50b40cb21bd4ae to your computer and use it in GitHub Desktop.
Save phenomnomnominal/57816f173591a3914e50b40cb21bd4ae to your computer and use it in GitHub Desktop.
workerRequire example
// 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