Socket
Socket
Sign inDemoInstall

jetworker

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jetworker

jetworker easy way for community with WebWorker


Version published
Maintainers
1
Install size
7.79 kB
Created

Readme

Source

jetworker

NPM

install size dependencies

Version License Downloads

jetworker easy way for community with WebWorker

Browser compatibility desktop

ChromeFirefoxInternet ExplorerOperaSafari
43.51010.64

Browser compatibility mobile

AndroidChromeFirefoxInternet ExplorerOperaSafari
4.443.51011.55.1

install

npm install jetworker --save

jetwork has two section Client and Service

Client for use in main thread website or webapp

Service for use in WebWorker file

import Client

const Client = require("jetworker/client");
//or
import Client from "jetworker/client";

import Service

const Service = require("jetworker/service");
//or
import Service from "jetworker/service";

use web

import Client from "jetworker/client";

const { post } = new Client("./worker.js");

/**
 * post(name, data, callback)
 * @param {string} name is function name in worker
 * @param {any} data send to worker
 * @param {function} callback for recive response from worker
 * @returns {undefined} nothing
 */
post("multiple", { a: 2, b: 3 }, result => console.log(result));

in worker.js

import Service from "jetworker/service";

const { on } = new Service();

function multiple(data, response) {
  response(data.a * data.b);
}

/**
 * service.on(name, process)
 * @param {string} name function name for call in client
 * @param {function} process function, data is data recived from client and post is function for send result to client
 */
on("multiple", multiple);

Migration from v1 to v2

You should use post instead emit inside client

- const { emit } = new Client("./worker.js");
+ const { post } = new Client("./worker.js");

FAQs

Last updated on 22 Feb 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc