Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Corrected some issues in the readme and jazz'd it up a bit #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,35 @@ See the design document
### Example

#### Master source

```javascript
var sys = require('sys');
var Worker = require('webworker');

var w = new Worker('foo.js');
var Worker = require('webworker').Worker;

var cDir = process.cwd()+'/'; // gets the path of the executing master process
var wPath = cDir+'foo.js'; // if you have the worker in the same directory as master
//var wPath = 'foo.js'; // if you have the worker in /foo.js

var w = new Worker(wPath);

w.onmessage = function(e) {
sys.debug('Received mesage: ' + sys.inspect(e));
w.terminate();
};

w.postMessage({ foo : 'bar' });
```

#### Worker source

```javascript
var sys = require('sys');
onmessage = function(e) {
postMessage({ test : 'this is a test' });
};

onclose = function() {
sys.debug('Worker shuttting down.');
};
```

### API

Expand Down