Skip to content

Instantly share code, notes, and snippets.

@phenomnomnominal
Last active Jan 20, 2021
Embed
What would you like to do?
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