🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

worker-builder

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

worker-builder

A library to simplify the usage of Webworkers

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

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());
});

Keywords

webworker

FAQs

Package last updated on 19 Jan 2017

Did you know?

Socket

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.

Install

Related posts