From c7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 Mon Sep 17 00:00:00 2001 From: yo mama Date: Sat, 4 Apr 2015 01:00:59 -0700 Subject: first --- node_modules/webworker-threads/src/worker.js | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 node_modules/webworker-threads/src/worker.js (limited to 'node_modules/webworker-threads/src/worker.js') diff --git a/node_modules/webworker-threads/src/worker.js b/node_modules/webworker-threads/src/worker.js new file mode 100644 index 0000000..004bb54 --- /dev/null +++ b/node_modules/webworker-threads/src/worker.js @@ -0,0 +1,46 @@ +function Worker(){ + var Threads; + Threads = this; + return (function(){ + var prototype = constructor.prototype; + function constructor(code){ + var t, this$ = this; + this.thread = t = Threads.create(); + t.on('message', function(args){ + return typeof this$.onmessage === 'function' ? this$.onmessage({ + data: args + }) : void 8; + }); + t.on('error', function(args){ + return typeof this$.onerror === 'function' ? this$.onerror(args) : void 8; + }); + t.on('close', function(){ + return t.destroy(); + }); + this.terminate = function(){ + return t.destroy(); + }; + this.addEventListener = function(event, cb){ + if (event === 'message') { + return this$.onmessage = cb; + } else { + return t.on(event, cb); + } + }; + this.dispatchEvent = function(event){ + return t.emitSerialized(event.type, event); + }; + this.postMessage = function(data){ + return t.emitSerialized('message', { + data: data + }); + }; + if (typeof code === 'function') { + t.eval("(" + code + ")()"); + } else if (code != null) { + t.load(code); + } + } + return constructor; + }()); +} -- cgit v1.2.3-70-g09d2