1.0.6 • Published 9 months ago

ino-worker v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago
import { RunInWorker } from "ino-worker";

// The function to be executed in the web worker
const myFunction = (count) => {

    let sum = 0;

    for (let i = 0; i < count; i++) {
        sum += i;
    }

    return sum;

};

// or you can use a string representation of the function
const myFunction = `(count) => {

    let sum = 0;

    for (let i = 0; i < count; i++) {
        sum += i;
    }

    return sum;

}`;

const arg = 100000000;

// Call RunInWorker with the function and its arguments to execute it in a web worker
RunInWorker(myFunction, arg)
    .then((sum) => {
        console.log("Result from worker ", sum);
    })
    .catch((err) => {
        console.error(err);
    });
1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago