From 0431425a6393a1bc39d342d66f6047e1307d23ed Mon Sep 17 00:00:00 2001
From: Jason Mulligan <jason.mulligan@avoidwork.com>
Date: Tue, 29 Sep 2015 20:36:24 -0400
Subject: [PATCH] Minor tweaks

---
 lib/worker.js | 6 +++---
 src/worker.js | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/worker.js b/lib/worker.js
index 6d59a12..afb5dfe 100644
--- a/lib/worker.js
+++ b/lib/worker.js
@@ -3,7 +3,7 @@
 var fs = require("fs");
 var path = require("path");
 var vm = require("vm");
-var noop = path.join(__dirname, "noop.js");
+var noop = require(path.join(__dirname, "noop.js"));
 
 function trim(arg) {
 	return arg.replace(/^(\s+|\t+|\n+)|(\s+|\t+|\n+)$/g, "");
@@ -63,11 +63,11 @@ process.once("message", function (obj) {
 	});
 
 	process.on("message", function (msg) {
-		global.self.onmessage(JSON.parse(msg));
+		(global.self.onmessage || global.onmessage || noop)(JSON.parse(msg));
 	});
 
 	process.on("error", function (err) {
-		global.self.onerror(err);
+		(global.self.onerror || global.onerror || noop)(err);
 	});
 
 	if (typeof exp === "function") {
diff --git a/src/worker.js b/src/worker.js
index 7e1a6cc..ee324f6 100644
--- a/src/worker.js
+++ b/src/worker.js
@@ -1,7 +1,7 @@
 const fs = require("fs");
 const path = require("path");
 const vm = require("vm");
-const noop = path.join(__dirname, "noop.js");
+const noop = require(path.join(__dirname, "noop.js"));
 
 function trim (arg) {
 	return arg.replace(/^(\s+|\t+|\n+)|(\s+|\t+|\n+)$/g, "");
@@ -56,11 +56,11 @@ process.once("message", function (obj) {
 	});
 
 	process.on("message", function (msg) {
-		global.self.onmessage(JSON.parse(msg));
+		(global.self.onmessage || global.onmessage || noop)(JSON.parse(msg));
 	});
 
 	process.on("error", function (err) {
-		global.self.onerror(err);
+		(global.self.onerror || global.onerror || noop)(err);
 	});
 
 	if (typeof exp === "function") {
-- 
GitLab