PHP 8.2.30
Preview: progressEventReducer.js Size: 1.21 KB
/home/byroehnu/.trash/node_modules11/axios/lib/helpers/progressEventReducer.js

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 => {
    const loaded = e.loaded;
    const total = e.lengthComputable ? e.total : undefined;
    const progressBytes = loaded - bytesNotified;
    const rate = _speedometer(progressBytes);
    const inRange = loaded <= total;

    bytesNotified = loaded;

    const data = {
      loaded,
      total,
      progress: total ? (loaded / total) : undefined,
      bytes: progressBytes,
      rate: rate ? rate : undefined,
      estimated: rate && total && inRange ? (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));

Directory Contents

Dirs: 0 × Files: 32

Name Size Perms Modified Actions
3.59 KB lrw-r--r-- 2026-02-20 03:53:04
Edit Download
1.41 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
444 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
1.54 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
372 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
382 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
1.33 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
1.30 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
746 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
2.01 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
2.11 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
2.90 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
1.33 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
1.72 KB lrw-r--r-- 2026-02-20 03:53:06
Edit Download
618 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
371 B lrw-r--r-- 2026-02-20 03:53:06
Edit Download
420 B lrw-r--r-- 2026-02-20 03:53:08
Edit Download
56 B lrw-r--r-- 2026-02-20 03:53:08
Edit Download
1.35 KB lrw-r--r-- 2026-02-20 03:53:08
Edit Download
151 B lrw-r--r-- 2026-02-20 03:53:08
Edit Download
1.21 KB lrw-r--r-- 2026-02-20 03:53:08
Edit Download
318 B lrw-r--r-- 2026-02-20 03:53:08
Edit Download
351 B lrw-r--r-- 2026-02-20 03:53:18
Edit Download
2.15 KB lrw-r--r-- 2026-02-20 03:53:08
Edit Download
1.07 KB lrw-r--r-- 2026-02-20 03:53:08
Edit Download
566 B lrw-r--r-- 2026-02-20 03:53:08
Edit Download
852 B lrw-r--r-- 2026-02-20 03:53:10
Edit Download
5.97 KB lrw-r--r-- 2026-02-20 03:53:10
Edit Download
540 B lrw-r--r-- 2026-02-20 03:53:10
Edit Download
1.65 KB lrw-r--r-- 2026-02-20 03:53:10
Edit Download
2.72 KB lrw-r--r-- 2026-02-20 03:53:12
Edit Download
681 B lrw-r--r-- 2026-02-20 03:53:12
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).