
Research
/Security News
737 Chrome VPN Extensions Linked to Brand Impersonation and Browser Traffic Redirection
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.
Run a function in a Worker thread and get back a promise
npm install offload-fn
import offloadFunction from 'offload-fn';
const result = await offloadFunction((a, b) => a + b, 2, 3);
//=> 5
// CPU-intensive work
const sum = await offloadFunction(n => {
let total = 0;
for (let i = 0; i < n; i++) {
total += i;
}
return total;
}, 1_000_000);
Returns a Promise that resolves with the function's return value.
Serializes the function to a string and runs it inside a Worker thread. Arguments and return values must be serializable via the structured clone algorithm.
Type: Function
The function to execute in a Worker thread.
Type: unknown[]
Arguments to pass to the function.
MIT
FAQs
Run a function in a Worker thread and get back a promise
We found that offload-fn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.