Skip to content

Commit 3aeb647

Browse files
committed
Change the meaning of evalPath
* ie10shim doesn't do anything anymore * path got renamed to evalPath * if evalPath is null, IE10 will fall back to a synchronous solution References #36.
1 parent 4d82c98 commit 3aeb647

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

lib/parallel.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
};
6868

6969
var defaults = {
70-
ie10shim: !isNode,
71-
path: (isNode ? __dirname + '/' : 'lib/') + 'eval.js',
70+
evalPath: isNode ? __dirname + '/eval.js' : null,
7271
maxWorkers: isNode ? require('os').cpus().length : 4,
7372
synchronous: true
7473
};
@@ -118,7 +117,7 @@
118117
var wrk;
119118
var src = this.getWorkerSource(cb);
120119
if (isNode) {
121-
wrk = new Worker(this.options.path);
120+
wrk = new Worker(this.options.evalPath);
122121
wrk.postMessage(src);
123122
} else {
124123
if (Worker === undefined) {
@@ -127,8 +126,8 @@
127126

128127
try {
129128
if (this.requiredScripts.length !== 0) {
130-
if (this.options.ie10shim) {
131-
wrk = new Worker(this.options.path);
129+
if (this.options.evalPath !== null) {
130+
wrk = new Worker(this.options.evalPath);
132131
wrk.postMessage(src);
133132
} else {
134133
throw new Error('Can\'t use required scripts without eval.js!');
@@ -140,8 +139,8 @@
140139
wrk = new Worker(url);
141140
}
142141
} catch (e) {
143-
if (this.options.ie10shim) { // blob/url unsupported, cross-origin error
144-
wrk = new Worker(this.options.path);
142+
if (this.options.evalPath !== null) { // blob/url unsupported, cross-origin error
143+
wrk = new Worker(this.options.evalPath);
145144
wrk.postMessage(src);
146145
} else {
147146
throw e;

test/api.spec.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
});
88

99
it('should define a .then(cb) function', function () {
10-
var p = new Parallel([1, 2, 3]);
10+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
1111
expect(p.then).toEqual(jasmine.any(Function));
1212
});
1313

1414
it('should define a .map(cb) function', function () {
15-
var p = new Parallel([1, 2, 3]);
15+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
1616
expect(p.map).toEqual(jasmine.any(Function));
1717
});
1818

1919
it('should define a require(string|function|{ name: string, fn: function }) function', function () {
20-
var p = new Parallel([1, 2, 3]);
20+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
2121
expect(p.require).toEqual(jasmine.any(Function));
2222
});
2323

2424
it('should execute a .then function without an operation immediately', function () {
25-
var p = new Parallel([1, 2, 3]);
25+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
2626
expect(p.then).toEqual(jasmine.any(Function));
2727

2828
var done = false;
@@ -37,7 +37,7 @@
3737
});
3838

3939
it('should execute .spawn() correctly', function () {
40-
var p = new Parallel([1, 2, 3]);
40+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
4141

4242
var done = false;
4343
var result = null;
@@ -61,7 +61,7 @@
6161
});
6262

6363
it('should .map() correctly', function () {
64-
var p = new Parallel([1, 2, 3]);
64+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
6565

6666
var done = false;
6767
var result = null;
@@ -85,7 +85,7 @@
8585
});
8686

8787
it('should queue map work correctly', function () {
88-
var p = new Parallel([1, 2, 3], { maxWorkers: 2 });
88+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js', maxWorkers: 2 });
8989

9090
var done = false;
9191
var result = null;
@@ -109,7 +109,7 @@
109109
});
110110

111111
it('should chain .map() correctly', function () {
112-
var p = new Parallel([1, 2, 3]);
112+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
113113

114114
var done = false;
115115
var result = null;
@@ -135,7 +135,7 @@
135135
});
136136

137137
it('should mix .spawn and .map() correctly', function () {
138-
var p = new Parallel([1, 2, 3]);
138+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
139139

140140
var done = false;
141141
var result = null;
@@ -165,7 +165,7 @@
165165
});
166166

167167
it('should execute .reduce() correctly', function () {
168-
var p = new Parallel([1, 2, 3]);
168+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
169169
var done = false;
170170
var result = null;
171171

@@ -188,7 +188,7 @@
188188
});
189189

190190
it('should process data returned from .then()', function () {
191-
var p = new Parallel([1, 2, 3]);
191+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
192192

193193
var done = false;
194194
var result = null;
@@ -219,7 +219,7 @@
219219

220220
if (!isNode) {
221221
it('should work with require()d scripts (web-exclusive)', function () {
222-
var p = new Parallel([1, 2, 3]);
222+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
223223
p.require('../test/test.js'); // relative to eval.js
224224

225225
var done = false;
@@ -248,7 +248,7 @@
248248
var fn = function (el, amount) {
249249
return el + amount;
250250
};
251-
var p = new Parallel([1, 2, 3]);
251+
var p = new Parallel([1, 2, 3], { evalPath: isNode ? undefined : 'lib/eval.js' });
252252
p.require({ name: 'fn', fn: fn });
253253

254254
var done = false;

0 commit comments

Comments
 (0)