Skip to content

Instantly share code, notes, and snippets.

@phenomnomnominal
Last active January 20, 2021 01:18
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