Skip to content

Commit

Permalink
DRY up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Jun 18, 2021
1 parent 31b1127 commit 830d73e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/fake-timers-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -1614,22 +1614,23 @@ function withGlobal(_global) {
}

for (i = 0, l = clock.methods.length; i < l; i++) {
if (clock.methods[i] === "hrtime") {
const nameOfMethodToReplace = clock.methods[i];
if (nameOfMethodToReplace === "hrtime") {
if (
_global.process &&
typeof _global.process.hrtime === "function"
) {
hijackMethod(_global.process, clock.methods[i], clock);
hijackMethod(_global.process, nameOfMethodToReplace, clock);
}
} else if (clock.methods[i] === "nextTick") {
} else if (nameOfMethodToReplace === "nextTick") {
if (
_global.process &&
typeof _global.process.nextTick === "function"
) {
hijackMethod(_global.process, clock.methods[i], clock);
hijackMethod(_global.process, nameOfMethodToReplace, clock);
}
} else {
hijackMethod(_global, clock.methods[i], clock);
hijackMethod(_global, nameOfMethodToReplace, clock);
}
}

Expand Down

0 comments on commit 830d73e

Please sign in to comment.