Skip to content

Commit

Permalink
style: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Oct 10, 2019
1 parent e9708cc commit ccbefa2
Show file tree
Hide file tree
Showing 2 changed files with 604 additions and 591 deletions.
64 changes: 38 additions & 26 deletions src/lolex-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ function withGlobal(_global) {
return ks;
};


var originalSetTimeout = _global.setImmediate || _global.setTimeout;

/**
Expand Down Expand Up @@ -836,7 +835,12 @@ function withGlobal(_global) {
nanos = nanosTotal;
var tickFrom = clock.now;
var previous = clock.now;
var timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
var timer,
firstException,
oldNow,
nextPromiseTick,
compensationCheck,
postTimerCall;

clock.duringTick = true;

Expand All @@ -852,7 +856,7 @@ function withGlobal(_global) {
function doTickInner() {
// perform each timer in the requested range
timer = firstTimerInRange(clock, tickFrom, tickTo);
while (timer && tickFrom <= tickTo) {
while (tickFrom <= tickTo) {
if (clock.timers[timer.id]) {
tickFrom = timer.callAt;
clock.now = timer.callAt;
Expand Down Expand Up @@ -914,17 +918,19 @@ function withGlobal(_global) {
}
}

nextPromiseTick = isAsync && function () {
try {
compensationCheck();
postTimerCall();
doTickInner();
} catch (e) {
reject(e);
}
};
nextPromiseTick =
isAsync &&
function() {
try {
compensationCheck();
postTimerCall();
doTickInner();
} catch (e) {
reject(e);
}
};

compensationCheck = function () {
compensationCheck = function() {
// compensate for any setSystemTime() call during timer callback
if (oldNow !== clock.now) {
tickFrom += clock.now - oldNow;
Expand All @@ -933,7 +939,7 @@ function withGlobal(_global) {
}
};

postTimerCall = function () {
postTimerCall = function() {
timer = firstTimerInRange(clock, previous, tickTo);
previous = tickFrom;
};
Expand All @@ -950,8 +956,8 @@ function withGlobal(_global) {

if (typeof global.Promise !== "undefined") {
clock.tickAsync = function tickAsync(ms) {
return new global.Promise(function (resolve, reject) {
originalSetTimeout(function () {
return new global.Promise(function(resolve, reject) {
originalSetTimeout(function() {
try {
doTick(ms, true, resolve, reject);
} catch (e) {
Expand Down Expand Up @@ -982,8 +988,8 @@ function withGlobal(_global) {

if (typeof global.Promise !== "undefined") {
clock.nextAsync = function nextAsync() {
return new global.Promise(function (resolve, reject) {
originalSetTimeout(function () {
return new global.Promise(function(resolve, reject) {
originalSetTimeout(function() {
try {
var timer = firstTimer(clock);
if (!timer) {
Expand All @@ -1001,7 +1007,7 @@ function withGlobal(_global) {
}
clock.duringTick = false;

originalSetTimeout(function () {
originalSetTimeout(function() {
if (err) {
reject(err);
} else {
Expand Down Expand Up @@ -1045,10 +1051,10 @@ function withGlobal(_global) {

if (typeof global.Promise !== "undefined") {
clock.runAllAsync = function runAllAsync() {
return new global.Promise(function (resolve, reject) {
return new global.Promise(function(resolve, reject) {
var i = 0;
function doRun() {
originalSetTimeout(function () {
originalSetTimeout(function() {
try {
var numTimers;
if (i < clock.loopLimit) {
Expand All @@ -1057,7 +1063,8 @@ function withGlobal(_global) {
return;
}

numTimers = Object.keys(clock.timers).length;
numTimers = Object.keys(clock.timers)
.length;
if (numTimers === 0) {
resolve(clock.now);
return;
Expand All @@ -1071,8 +1078,13 @@ function withGlobal(_global) {
return;
}

reject(new Error("Aborting after running " + clock.loopLimit
+ " timers, assuming an infinite loop!"));
reject(
new Error(
"Aborting after running " +
clock.loopLimit +
" timers, assuming an infinite loop!"
)
);
} catch (e) {
reject(e);
}
Expand All @@ -1095,8 +1107,8 @@ function withGlobal(_global) {

if (typeof global.Promise !== "undefined") {
clock.runToLastAsync = function runToLastAsync() {
return new global.Promise(function (resolve, reject) {
originalSetTimeout(function () {
return new global.Promise(function(resolve, reject) {
originalSetTimeout(function() {
try {
var timer = lastTimer(clock);
if (!timer) {
Expand Down
Loading

0 comments on commit ccbefa2

Please sign in to comment.