worker-builder
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

worker-builder

This library will only work inside a webpack bundle

Usage

run

Applies a givent method on a given argument inside a WebWorker instance.

The worker method runs in its own context, but you can use imported libraries.

Example:

import * as workerBuilder from "worker-builder";
import * as _ from "underscore";

workerBuilder.run<{start: number, end: number},number[]>({start: 0, end: 100},options=>{
    function isPrime(canidate: number): boolean{
        for(let i=canidate-1;i>1;i--){
            if(canidate % i == 0){
                return false;
            }
        }
        return true;
    }
    return _.range(options.start,options.end).filter(isPrime);
})
.then(result=>{
    document.writeln(result.toString());
});

Package Sidebar

Install

npm i worker-builder

Weekly Downloads

6

Version

0.0.1

License

MIT

Last publish

Collaborators

  • cedware