Socket
Socket
Sign inDemoInstall

xgplayer-streaming-shared

Package Overview
Dependencies
2
Maintainers
8
Versions
178
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.17 to 3.0.18-alpha.0

3

es/services/bandwidth.d.ts
export class BandwidthService {
_chunkSpeeds: any[];
_chunkSpeed: number;
_chunkCache: any[];
_speeds: any[];

@@ -4,0 +5,0 @@ addRecord(totalByte: any, ms: any): void;

import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from "../_virtual/_rollupPluginBabelHelpers.js";
var SKIP_SMALL_CHUNK = 1e3;
var MAX_CHUNK_SAVE_SIZE = 100;
var MAX_SEGMENT_SAVE_SIZE = 3;
var BandwidthService = /* @__PURE__ */ function() {
function BandwidthService2() {
_classCallCheck(this, BandwidthService2);
_defineProperty(this, "_chunkSpeeds", []);
_defineProperty(this, "_chunkSpeed", 0);
_defineProperty(this, "_chunkCache", []);
_defineProperty(this, "_speeds", []);

@@ -14,3 +18,3 @@ }

this._speeds.push(8e3 * totalByte / ms);
this._speeds = this._speeds.slice(-3);
this._speeds = this._speeds.slice(-MAX_SEGMENT_SAVE_SIZE);
}

@@ -20,6 +24,12 @@ }, {

value: function addChunkRecord(totalByte, ms) {
if (!totalByte || !ms)
if (!totalByte || !ms || totalByte < SKIP_SMALL_CHUNK)
return;
this._chunkSpeeds.push(8e3 * totalByte / ms);
this._chunkSpeeds = this._chunkSpeeds.slice(-100);
this._chunkSpeed = 8e3 * totalByte / ms;
this._chunkCache.push({
size: totalByte,
duration: ms
});
if (this._chunkCache.length > MAX_CHUNK_SAVE_SIZE) {
this._chunkCache = this._chunkCache.slice(-MAX_CHUNK_SAVE_SIZE);
}
}

@@ -29,3 +39,3 @@ }, {

value: function getAvgSpeed() {
if (!this._chunkSpeeds.length && !this._speeds.length)
if (!this._chunkCache.length && !this._speeds.length)
return 0;

@@ -37,5 +47,9 @@ if (this._speeds.length) {

}
return this._chunkSpeeds.reduce(function(a, c) {
return a += c;
}) / this._chunkSpeeds.length;
var totalSize = this._chunkCache.reduce(function(a, c) {
return a += c.size;
}, 0);
var totalDuration = this._chunkCache.reduce(function(a, c) {
return a += c.duration;
}, 0);
return 8e3 * totalSize / totalDuration;
}

@@ -45,3 +59,3 @@ }, {

value: function getLatestSpeed() {
if (!this._chunkSpeeds.length && !this._speeds.length)
if (!this._chunkCache.length && !this._speeds.length)
return 0;

@@ -51,3 +65,3 @@ if (this._speeds.length) {

}
return this._chunkSpeeds[this._chunkSpeeds.length - 1];
return this._chunkSpeed;
}

@@ -57,3 +71,3 @@ }, {

value: function reset() {
this._chunkSpeeds = [];
this._chunkCache = [];
this._speeds = [];

@@ -60,0 +74,0 @@ }

{
"name": "xgplayer-streaming-shared",
"version": "3.0.17",
"version": "3.0.18-alpha.0",
"main": "dist/index.min.js",

@@ -18,3 +18,3 @@ "module": "es/index.js",

"access": "public",
"tag": "latest"
"tag": "alpha"
},

@@ -21,0 +21,0 @@ "license": "MIT",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc