New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

function-to-worker

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-to-worker

This package can get function and wrap it in web worker

latest
Source
npmnpm
Version
0.0.11
Version published
Maintainers
1
Created
Source

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

Keywords

worker

FAQs

Package last updated on 04 Apr 2019

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