Skip to content
Snippets Groups Projects
Commit c77e9d5a authored by Jason Mulligan's avatar Jason Mulligan
Browse files

Changing the order of execution & updating test, fixes #2

parent a119c860
No related branches found
No related tags found
No related merge requests found
Copyright (c) 2015, Jason Mulligan Copyright (c) 2016, Jason Mulligan
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
...@@ -9,7 +9,7 @@ Tiny WebWorker for Server ...@@ -9,7 +9,7 @@ Tiny WebWorker for Server
#### Creating a Worker from a file #### Creating a Worker from a file
The worker script: The worker script:
```javascript ```javascript
self.onmessage = function (ev) { onmessage = function (ev) {
postMessage(ev.data); postMessage(ev.data);
}; };
``` ```
......
...@@ -67,11 +67,11 @@ process.once("message", function (obj) { ...@@ -67,11 +67,11 @@ process.once("message", function (obj) {
}); });
process.on("message", function (msg) { process.on("message", function (msg) {
(global.self.onmessage || global.onmessage || noop)(JSON.parse(msg)); (global.onmessage || global.self.onmessage || noop)(JSON.parse(msg));
}); });
process.on("error", function (err) { process.on("error", function (err) {
(global.self.onerror || global.onerror || noop)(err); (global.onerror || global.self.onerror || noop)(err);
}); });
if (typeof exp === "function") { if (typeof exp === "function") {
......
{ {
"name": "tiny-worker", "name": "tiny-worker",
"version": "1.1.1", "version": "1.1.2",
"description": "Tiny WebWorker for Server", "description": "Tiny WebWorker for Server",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
......
...@@ -61,11 +61,11 @@ process.once("message", function (obj) { ...@@ -61,11 +61,11 @@ process.once("message", function (obj) {
}); });
process.on("message", function (msg) { process.on("message", function (msg) {
(global.self.onmessage || global.onmessage || noop)(JSON.parse(msg)); (global.onmessage || global.self.onmessage || noop)(JSON.parse(msg));
}); });
process.on("error", function (err) { process.on("error", function (err) {
(global.self.onerror || global.onerror || noop)(err); (global.onerror || global.self.onerror || noop)(err);
}); });
if (typeof exp === "function") { if (typeof exp === "function") {
......
self.onmessage = function (ev) { onmessage = function (ev) {
postMessage(ev.data); postMessage(ev.data);
}; };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment