Skip to content

Commit 3fe3af6

Browse files
committed
refactor: move getNetworkMultiplierFromString to WaitForHelper
1 parent e513db1 commit 3fe3af6

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

src/McpContext.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
type InstalledExtension,
4848
} from './utils/ExtensionRegistry.js';
4949
import {saveTemporaryFile} from './utils/files.js';
50-
import {WaitForHelper} from './WaitForHelper.js';
50+
import {getNetworkMultiplierFromString, WaitForHelper} from './WaitForHelper.js';
5151

5252
interface McpContextOptions {
5353
// Whether the DevTools windows are exposed as pages for debugging of DevTools.
@@ -61,23 +61,6 @@ interface McpContextOptions {
6161
const DEFAULT_TIMEOUT = 5_000;
6262
const NAVIGATION_TIMEOUT = 10_000;
6363

64-
function getNetworkMultiplierFromString(condition: string | null): number {
65-
const puppeteerCondition =
66-
condition as keyof typeof PredefinedNetworkConditions;
67-
68-
switch (puppeteerCondition) {
69-
case 'Fast 4G':
70-
return 1;
71-
case 'Slow 4G':
72-
return 2.5;
73-
case 'Fast 3G':
74-
return 5;
75-
case 'Slow 3G':
76-
return 10;
77-
}
78-
return 1;
79-
}
80-
8164
export class McpContext implements Context {
8265
browser: Browser;
8366
logger: Debugger;

src/WaitForHelper.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import {logger} from './logger.js';
88
import type {Page, Protocol, CdpPage} from './third_party/index.js';
9+
import {PredefinedNetworkConditions} from './third_party/index.js';
910

1011
export class WaitForHelper {
1112
#abortController = new AbortController();
@@ -160,3 +161,22 @@ export class WaitForHelper {
160161
}
161162
}
162163
}
164+
165+
export function getNetworkMultiplierFromString(
166+
condition: string | null,
167+
): number {
168+
const puppeteerCondition =
169+
condition as keyof typeof PredefinedNetworkConditions;
170+
171+
switch (puppeteerCondition) {
172+
case 'Fast 4G':
173+
return 1;
174+
case 'Slow 4G':
175+
return 2.5;
176+
case 'Fast 3G':
177+
return 5;
178+
case 'Slow 3G':
179+
return 10;
180+
}
181+
return 1;
182+
}

0 commit comments

Comments
 (0)