/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/utils/networkInfo.ts
38 строк
906 B
Anton Standrik
feat: improve errors diagnostics (#3537)
11 мар 2026, 10:48
Не верифицирован
11 мар 2026, 10:48
3ce7547
Код
Авторство
О чём код?
interface NetworkConnectionInfo { effectiveType?: string; rtt?: number; downlink?: number; } interface NavigatorWithConnection extends Navigator { connection?: NetworkConnectionInfo; } export interface NetworkContext { online: boolean; effectiveType?: string; rtt?: number; downlink?: number; } export function getNetworkContext(): NetworkContext { const result: NetworkContext = { online: navigator.onLine, }; const nav = navigator as NavigatorWithConnection; const conn = nav.connection; if (conn) { if (typeof conn.effectiveType === 'string') { result.effectiveType = conn.effectiveType; } if (typeof conn.rtt === 'number') { result.rtt = conn.rtt; } if (typeof conn.downlink === 'number') { result.downlink = conn.downlink; } } return result; }