hr.worker

2.0.1 • Public • Published

hr.worker Build Status

Utility for web-worker communication

Installation

$ npm install hr.worker

Documentation

Create a web-worker "myworker.js" using:

var TaskWorker = require("hr.worker");

var worker = new TaskWorker();

// Register some methods
worker.register({
	// Task can be sync
	hello: function() {
		return "World";
	},

	// Or async:
	testAsync: function() {
		return doSomethingSync()
		.then(function() {
			// it should return a promise
		});
	}
});

// Run the worker
worker.run();

And in your application, access the web-worker using:

var worker = new TaskWorker({
	script: "myworker.js"
});


// Call a method
worker.callMethod("hello")
.then(function(msg) {

});

// Or create a binded nethod:
var testAsync = worker.method("testAsync");

Readme

Keywords

none

Package Sidebar

Install

npm i hr.worker

Weekly Downloads

5

Version

2.0.1

License

none

Last publish

Collaborators

  • samypesse