Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Sep 20, 2024
1 parent 34bf230 commit 3d5ee7e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/timeline-state-resolver/src/__tests__/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ declare global {
/** setTimeout (not affected by jest.fakeTimers) */
const setTimeoutOrg = setTimeout
/** Sleep for a */
export function waitTime(ms: number): Promise<void> {
export async function waitTime(ms: number): Promise<void> {
return new Promise((resolve) => setTimeoutOrg(resolve, ms))
}

/** An actual monotonic time, not affected by jest.fakeTimers */
export const realTimeNow = performance.now
/** The current time, not affected by jest.fakeTimers */
export const realTimeNow = Date.now.bind(Date)
/**
* Executes {expectFcn} intermittently until it doesn't throw anymore.
* Waits up to {maxWaitTime} ms, then throws the latest error.
Expand All @@ -109,8 +109,9 @@ export async function waitUntil(

const previousErrors: string[] = []

// eslint-disable-next-line no-constant-condition
while (true) {
mockTime?.advanceTimeTicks(100)
await mockTime?.advanceTimeTicks(100)
await waitTime(100)
try {
await Promise.resolve(expectFcn())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
import { ThreadedClass } from 'threadedclass'
import { VMixDevice } from '..'
import { MockTime } from '../../../__tests__/mockTime'
import '../../../__tests__/lib'
import { CommandContext } from '../vMixCommands'
import { prefixAddedInput } from './mockState'
import { addConnections } from '../../../__tests__/lib'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ export class ConnectionManager extends EventEmitter<ConnectionManagerEvents> {
this._updating = false

// wait until next
const nextTime = Array.from(this._connectionAttempts.values()).reduce((a, b) => (a.next < b.next ? a : b))
const nextTime = Array.from(this._connectionAttempts.values()).reduce((a, b) => (a.next < b.next ? a : b), {
last: Date.now(), // not used
next: Date.now() + 4000, // in 4 seconds
})
this._nextAttempt = setTimeout(() => {
this._updateConnections()
}, nextTime.next - Date.now())
Expand Down

0 comments on commit 3d5ee7e

Please sign in to comment.