2.0.3 • Published 3 years ago

jetworker v2.0.3

Weekly downloads
125
License
ISC
Repository
github
Last release
3 years ago

jetworker

NPM

install size dependencies

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

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago