Skip to content

Commit 3eeebd2

Browse files
committed
Fixes worker creation with the ie10 shim.
1 parent 860e23e commit 3eeebd2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/parallel.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
var defaults = {
7070
ie10shim: !isNode,
71-
path: (isNode ? __dirname + '/' : '') + 'eval.js',
71+
path: (isNode ? __dirname + '/' : 'lib/') + 'eval.js',
7272
maxWorkers: isNode ? require('os').cpus().length : 4
7373
};
7474

@@ -79,7 +79,7 @@
7979
this.operation.resolve(null, this.data);
8080
}
8181

82-
Parallel.getWorkerSource = function (cb) {
82+
Parallel.prototype.getWorkerSource = function (cb) {
8383
if (isNode) {
8484
return 'process.on("message", function(e) {process.send(JSON.stringify((' + cb.toString() + ')(JSON.parse(e).data)))})';
8585
} else {
@@ -89,19 +89,20 @@
8989

9090
Parallel.prototype._spawnWorker = function (cb) {
9191
var wrk;
92+
var src = this.getWorkerSource(cb);
9293
if (isNode) {
9394
wrk = new Worker(this.options.path);
94-
wrk.postMessage(Parallel.getWorkerSource(cb));
95+
wrk.postMessage(src);
9596
} else {
9697
try {
97-
var blob = new Blob([Parallel.getWorkerSource(cb)], { type: 'text/javascript' });
98+
var blob = new Blob([src], { type: 'text/javascript' });
9899
var url = URL.createObjectURL(blob);
99100

100101
wrk = new Worker(url);
101102
} catch (e) {
102103
if (this.options.ie10shim) { // blob/url unsupported, cross-origin error
103-
worker = new Worker(this.options.path);
104-
worker.postMessage(str);
104+
wrk = new Worker(this.options.path);
105+
wrk.postMessage(src);
105106
} else {
106107
throw e;
107108
}

0 commit comments

Comments
 (0)