27 lines
634 B
JavaScript
27 lines
634 B
JavaScript
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
|
||
|
exports.default = function (workerFactory) {
|
||
|
var worker = new _events.EventEmitter();
|
||
|
worker.addEventListener = worker.on;
|
||
|
workerFactory(worker);
|
||
|
var client = {
|
||
|
onmessage: function onmessage() {},
|
||
|
postMessage: function postMessage(msg) {
|
||
|
process.nextTick(function () {
|
||
|
return worker.emit('message', { data: msg });
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
worker.postMessage = function (msg) {
|
||
|
process.nextTick(function () {
|
||
|
return client.onmessage({ data: msg });
|
||
|
});
|
||
|
};
|
||
|
return client;
|
||
|
};
|
||
|
|
||
|
var _events = require('events');
|