Skip to content

Commit 767eada

Browse files
committed
Added initial yarn support
1 parent 72bf558 commit 767eada

File tree

5 files changed

+2277
-29
lines changed

5 files changed

+2277
-29
lines changed

lib/Some.js

Whitespace-only changes.

lib/eval.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* @flow
3-
*/
1+
// @flow
42
const isNode = typeof module !== 'undefined' && module.exports;
53

64
if (isNode) {

lib/parallel.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,13 @@ function Parallel(data: Object, options: Object) {
7878
Parallel.isSupported = function isSupported() { return _supports; };
7979

8080
Parallel.prototype.getWorkerSource = function getWorkerSource(cb, env) {
81-
const that = this;
8281
let preStr = '';
8382
let i = 0;
8483
if (!isNode && this.requiredScripts.length !== 0) {
8584
preStr += `importScripts("${this.requiredScripts.join('","')}");\r\n`;
8685
}
8786

88-
for (i = 0; i < this.requiredFunctions.length; ++i) {
87+
for (i = 0; i < this.requiredFunctions.length; i++) {
8988
if (this.requiredFunctions[i].name) {
9089
preStr += `var ${this.requiredFunctions[i].name} = ${this.requiredFunctions[i].fn.toString()};`;
9190
} else {
@@ -105,19 +104,22 @@ Parallel.prototype.getWorkerSource = function getWorkerSource(cb, env) {
105104
};
106105

107106
Parallel.prototype.require = function require(...args) {
108-
let func;
109-
110-
for (let i = 0; i < args.length; i++) {
111-
func = args[i];
112-
113-
if (typeof func === 'string') {
114-
this.requiredScripts.push(func);
115-
} else if (typeof func === 'function') {
116-
this.requiredFunctions.push({ fn: func });
117-
} else if (typeof func === 'object') {
118-
this.requiredFunctions.push(func);
107+
// @TODO: Use .map instead of .forEach
108+
args.forEach(arg => {
109+
switch (typeof arg) {
110+
case 'string':
111+
this.requiredScripts.push(arg);
112+
break;
113+
case 'function':
114+
this.requiredFunctions.push({ fn: arg });
115+
break;
116+
case 'object':
117+
this.requiredFunctions.push(arg);
118+
break;
119+
default:
120+
throw new Error('Only strings, functions, and objects can be required');
119121
}
120-
}
122+
});
121123

122124
return this;
123125
};
@@ -223,8 +225,8 @@ Parallel.prototype._spawnMapWorker = function _spawnMapWorker(i, cb, done, env,
223225
}
224226
};
225227

226-
Parallel.prototype.map = function map(cb, env) {
227-
const env = Object.assign({}, this.options.env, env || {});
228+
Parallel.prototype.map = function map(cb, env = {}) {
229+
env = Object.assign({}, this.options.env, env);
228230

229231
if (!this.data.length) {
230232
return this.spawn(cb, env);

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"babel-plugin-dev-expression": "^0.2.1",
3838
"babel-plugin-module-alias": "^1.6.0",
3939
"babel-plugin-syntax-flow": "^6.13.0",
40-
"babel-plugin-tcomb": "^0.3.17",
40+
"babel-plugin-tcomb": "^0.3.19",
4141
"babel-plugin-transform-flow-strip-types": "^6.14.0",
4242
"babel-plugin-transform-remove-console": "^6.8.0",
4343
"babel-plugin-transform-remove-debugger": "^6.8.0",
@@ -46,19 +46,19 @@
4646
"babel-preset-stage-0": "^6.16.0",
4747
"babel-register": "^6.16.3",
4848
"babel-runtime": "^6.11.6",
49-
"eslint": "^3.7.1",
49+
"eslint": "^3.8.1",
5050
"eslint-config-airbnb": "^12.0.0",
51-
"eslint-formatter-pretty": "^1.0.0",
51+
"eslint-formatter-pretty": "^1.1.0",
5252
"eslint-import-resolver-webpack": "^0.6.0",
5353
"eslint-nibble-ignore": "^3.0.0",
54-
"eslint-plugin-flowtype": "^2.19.0",
55-
"eslint-plugin-flowtype-errors": "^1.3.0",
54+
"eslint-plugin-flowtype": "^2.20.0",
55+
"eslint-plugin-flowtype-errors": "^1.4.1",
5656
"eslint-plugin-fp": "^2.2.0",
57-
"eslint-plugin-import": "^2.0.0",
58-
"eslint-plugin-jsx-a11y": "^2.2.2",
59-
"eslint-plugin-mocha": "^4.6.0",
60-
"eslint-plugin-promise": "^2.0.1",
61-
"eslint-plugin-react": "^6.3.0",
57+
"eslint-plugin-import": "^2.0.1",
58+
"eslint-plugin-jsx-a11y": "^2.2.3",
59+
"eslint-plugin-mocha": "^4.7.0",
60+
"eslint-plugin-promise": "^3.3.0",
61+
"eslint-plugin-react": "^6.4.1",
6262
"jasmine-node": "x",
6363
"q": "x"
6464
},

0 commit comments

Comments
 (0)