2.0.1 • Published 9 years ago

hr.worker v2.0.1

Weekly downloads
16
License
-
Repository
github
Last release
9 years ago

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

9 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago