Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

jetworker

1.0.9 • Public • Published

jetworker

NPM

install size dependencies

Version License Downloads

jetworker easy way for community with WebWorker

Browser compatibility desktop

Chrome Firefox Internet Explorer Opera Safari
4 3.5 10 10.6 4

Browser compatibility mobile

Android Chrome Firefox Internet Explorer Opera Safari
4.4 4 3.5 10 11.5 5.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 client = new Client('./worker.js');
 
/**
 * client.emit(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
 */
client.emit(
  'multiple',   
  { a: 2, b: 3 }, 
  data => console.log(data),
);

in worker.js

import Service from 'jetworker/service';
 
const service = new Service();
 
/**
 * service.on(name, process)
 * @param {string} name function name for call in client
 * @param {function} process function, req is data recived from client and res is function for send result to client 
 */
service.on(  
  'multiple',   
  (req, res) => res(req.a * req.b) 
);

Keywords

none

install

npm i jetworker

Downloadsweekly downloads

2

version

1.0.9

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability