Skip to content

Commit f2d67a1

Browse files
committed
Satisfy linters
1 parent d68d117 commit f2d67a1

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "jshint src && jscs src && pulp build -- --censor-lib --strict",
5+
"build": "jshint src --verbose && jscs src && pulp build -- --censor-lib --strict",
66
"test": "pulp test"
77
},
88
"devDependencies": {
@@ -12,5 +12,8 @@
1212
"purescript-psa": "^0.5.0",
1313
"purescript": "^0.11.0",
1414
"rimraf": "^2.5.4"
15+
},
16+
"jscsConfig": {
17+
"validateIndentation": false
1518
}
1619
}

src/Control/Monad/Aff/Internal.js

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* globals setImmediate, clearImmediate, setTimeout, clearTimeout */
2+
/* jshint -W083, -W098 */
13
"use strict";
24

35
/*
@@ -29,7 +31,7 @@ var RECOVER = "Recover"; // Continue with `Either Error a` (via attempt)
2931
var RESUME = "Resume"; // Continue indiscriminately
3032
var FINALIZED = "Finalized"; // Marker for finalization
3133

32-
function Aff (tag, _1, _2, _3) {
34+
function Aff(tag, _1, _2, _3) {
3335
this.tag = tag;
3436
this._1 = _1;
3537
this._2 = _2;
@@ -117,6 +119,33 @@ exports._delay = function () {
117119
};
118120
}();
119121

122+
function runEff(eff) {
123+
try {
124+
eff();
125+
} catch (error) {
126+
setTimeout(function () {
127+
throw error;
128+
}, 0);
129+
}
130+
}
131+
132+
function runSync(left, right, eff) {
133+
try {
134+
return right(eff());
135+
} catch (error) {
136+
return left(error);
137+
}
138+
}
139+
140+
function runAsync(left, eff, k) {
141+
try {
142+
return eff(k)();
143+
} catch (error) {
144+
k(left(error))();
145+
return nonCanceler;
146+
}
147+
}
148+
120149
// Thread state machine
121150
var BLOCKED = 0; // No effect is running.
122151
var PENDING = 1; // An async effect is running.
@@ -164,7 +193,7 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
164193
// accidentally resuming the same thread. A common example may be invoking
165194
// the provided callback in `makeAff` more than once, but it may also be an
166195
// async effect resuming after the thread was already cancelled.
167-
function run (localRunTick) {
196+
function run(localRunTick) {
168197
while (1) {
169198
switch (status) {
170199
case BINDSTEP:
@@ -363,14 +392,16 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
363392
case COMPLETED:
364393
tmp = false;
365394
for (var k in joins) {
366-
tmp = true;
367-
runEff(joins[k](step));
395+
if ({}.hasOwnProperty.call(joins, k)) {
396+
tmp = true;
397+
runEff(joins[k](step));
398+
}
368399
}
369400
joins = tmp;
370401
// If we have an unhandled exception, and no other thread has joined
371402
// then we need to throw the exception in a fresh stack.
372403
if (isLeft(step) && !joins) {
373-
setTimeout(function() {
404+
setTimeout(function () {
374405
// Guard on joins because a completely synchronous thread can
375406
// still have an observer.
376407
if (!joins) {
@@ -390,7 +421,7 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
390421
}
391422
}
392423

393-
function addJoinCallback (cb) {
424+
function addJoinCallback(cb) {
394425
var jid = joinId++;
395426
joins[jid] = cb;
396427
return function (error) {
@@ -400,7 +431,7 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
400431
};
401432
}
402433

403-
function kill (error) {
434+
function kill(error) {
404435
return new Aff(ASYNC, function (cb) {
405436
return function () {
406437
// Shadow the canceler binding because it can potentially be
@@ -447,7 +478,7 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
447478
});
448479
}
449480

450-
function join () {
481+
function join() {
451482
return new Aff(ASYNC, function (cb) {
452483
return function () {
453484
if (status === COMPLETED) {
@@ -468,30 +499,3 @@ exports._launchAff = function (isLeft, fromLeft, fromRight, left, right, aff) {
468499
};
469500
};
470501
};
471-
472-
function runEff (eff) {
473-
try {
474-
eff();
475-
} catch (error) {
476-
setTimeout(function () {
477-
throw error;
478-
}, 0);
479-
}
480-
}
481-
482-
function runSync (left, right, eff) {
483-
try {
484-
return right(eff());
485-
} catch (error) {
486-
return left(error);
487-
}
488-
}
489-
490-
function runAsync (left, eff, k) {
491-
try {
492-
return eff(k)();
493-
} catch (error) {
494-
k(left(error))();
495-
return nonCanceler;
496-
}
497-
}

0 commit comments

Comments
 (0)