guardia-messenger/node_modules/axios/lib/helpers/progressEventReducer.js
DESKTOP-TKLFCPRython f29f525c77 refactor: 101.79.17.164 → zioinfo.co.kr 전체 도메인 변환 + Manager UI 배포
- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스)
- Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포
- 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 10:09:17 +09:00

55 lines
1.4 KiB
JavaScript

import speedometer from './speedometer.js';
import throttle from './throttle.js';
import utils from '../utils.js';
export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
let bytesNotified = 0;
const _speedometer = speedometer(50, 250);
return throttle((e) => {
if (!e || typeof e.loaded !== 'number') {
return;
}
const rawLoaded = e.loaded;
const total = e.lengthComputable ? e.total : undefined;
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
const progressBytes = Math.max(0, loaded - bytesNotified);
const rate = _speedometer(progressBytes);
bytesNotified = Math.max(bytesNotified, loaded);
const data = {
loaded,
total,
progress: total ? loaded / total : undefined,
bytes: progressBytes,
rate: rate ? rate : undefined,
estimated: rate && total ? (total - loaded) / rate : undefined,
event: e,
lengthComputable: total != null,
[isDownloadStream ? 'download' : 'upload']: true,
};
listener(data);
}, freq);
};
export const progressEventDecorator = (total, throttled) => {
const lengthComputable = total != null;
return [
(loaded) =>
throttled[0]({
lengthComputable,
total,
loaded,
}),
throttled[1],
];
};
export const asyncDecorator =
(fn) =>
(...args) =>
utils.asap(() => fn(...args));