0.0.11 • Published 5 years ago
function-to-worker v0.0.11
function-to-worker
function-to-worker
is a package designed for run any synchronous functions in web workers scope. It lets to make calculations
without blocking main js thread.
Usage
Package provide only one simple function which makes worker from passed function:
import createWorker from "function-to-worker";
const wantToCalculateItInWorker = number => number + 1;
const calculateInWorker = createWorker(wantToCalculateItInWorker);
function calculateInWorker from example above returns Promise which will resolved or rejected with value was returned by wantToCalculateItInWorker function. So, we can use it like this:
const addOneInWorker = async number => await calculateInWorker(number);