metatools-pararellworker

1.0.2 • Public • Published

@Metatools/Pararellworker

easy to use worker threads for parallel processing. With this library, you can implement parallel processing in a straightforward manner.

Install

npm install meatatools-parallworker

Usage

import {Controller} = from '@metatools-pararellworker';
const consrollerForProjectroot = new Controller('/workerpath/from/projectroot', workerNumber, workerOptions,  emitterOptions) 


consrollerForProjectroot.broadcast('broadcast event', 'this is broadcast!')
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);

const __dirname = path.dirname(__filename);
const controllerForRealtivePath  = new Controller(['./relative/for/worker.js', __dirname], workerNumber, workerOptions,  emitterOptions)

controllerForRealtivePath.message('singlemessage', )
// worker
import {Worker} = from 'metatools-pararellworker';


worker.on('brodcast', function(message){
    
    worker.postMessage('response', 'hello');

})


worker.postInit('done');

API

Event System

Controller and Worker is extend EventEmitter. Both post and accept message with event name.

if want more, see docs directry

Readme

Keywords

Package Sidebar

Install

npm i metatools-pararellworker

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

18.2 kB

Total Files

16

Last publish

Collaborators

  • hagiwara_takayuki