Socket
Socket
Sign inDemoInstall

@probe.gl/stats

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@probe.gl/stats - npm Package Compare versions

Comparing version 3.5.0-alpha.5 to 3.5.0

6

dist/es5/index.js

@@ -10,3 +10,3 @@ "use strict";

enumerable: true,
get: function () {
get: function get() {
return _stat.default;

@@ -17,3 +17,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _stats.default;

@@ -24,3 +24,3 @@ }

enumerable: true,
get: function () {
get: function get() {
return _hiResTimestamp.default;

@@ -27,0 +27,0 @@ }

@@ -10,2 +10,6 @@ "use strict";

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -15,4 +19,5 @@

class Stat {
constructor(name, type) {
var Stat = function () {
function Stat(name, type) {
(0, _classCallCheck2.default)(this, Stat);
(0, _defineProperty2.default)(this, "name", void 0);

@@ -37,119 +42,137 @@ (0, _defineProperty2.default)(this, "type", void 0);

setSampleSize(samples) {
this.sampleSize = samples;
return this;
}
(0, _createClass2.default)(Stat, [{
key: "setSampleSize",
value: function setSampleSize(samples) {
this.sampleSize = samples;
return this;
}
}, {
key: "incrementCount",
value: function incrementCount() {
this.addCount(1);
return this;
}
}, {
key: "decrementCount",
value: function decrementCount() {
this.subtractCount(1);
return this;
}
}, {
key: "addCount",
value: function addCount(value) {
this._count += value;
this._samples++;
incrementCount() {
this.addCount(1);
return this;
}
this._checkSampling();
decrementCount() {
this.subtractCount(1);
return this;
}
return this;
}
}, {
key: "subtractCount",
value: function subtractCount(value) {
this._count -= value;
this._samples++;
addCount(value) {
this._count += value;
this._samples++;
this._checkSampling();
this._checkSampling();
return this;
}
}, {
key: "addTime",
value: function addTime(time) {
this._time += time;
this.lastTiming = time;
this._samples++;
return this;
}
this._checkSampling();
subtractCount(value) {
this._count -= value;
this._samples++;
return this;
}
}, {
key: "timeStart",
value: function timeStart() {
this._startTime = (0, _hiResTimestamp.default)();
this._timerPending = true;
return this;
}
}, {
key: "timeEnd",
value: function timeEnd() {
if (!this._timerPending) {
return this;
}
this._checkSampling();
this.addTime((0, _hiResTimestamp.default)() - this._startTime);
this._timerPending = false;
return this;
}
this._checkSampling();
addTime(time) {
this._time += time;
this.lastTiming = time;
this._samples++;
this._checkSampling();
return this;
}
timeStart() {
this._startTime = (0, _hiResTimestamp.default)();
this._timerPending = true;
return this;
}
timeEnd() {
if (!this._timerPending) {
return this;
}
this.addTime((0, _hiResTimestamp.default)() - this._startTime);
this._timerPending = false;
this._checkSampling();
return this;
}
getSampleAverageCount() {
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
}
getSampleAverageTime() {
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
}
getSampleHz() {
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0;
}
getAverageCount() {
return this.samples > 0 ? this.count / this.samples : 0;
}
getAverageTime() {
return this.samples > 0 ? this.time / this.samples : 0;
}
getHz() {
return this.time > 0 ? this.samples / (this.time / 1000) : 0;
}
reset() {
this.time = 0;
this.count = 0;
this.samples = 0;
this.lastTiming = 0;
this.lastSampleTime = 0;
this.lastSampleCount = 0;
this._count = 0;
this._time = 0;
this._samples = 0;
this._startTime = 0;
this._timerPending = false;
return this;
}
_checkSampling() {
if (this._samples === this.sampleSize) {
this.lastSampleTime = this._time;
this.lastSampleCount = this._count;
this.count += this._count;
this.time += this._time;
this.samples += this._samples;
}, {
key: "getSampleAverageCount",
value: function getSampleAverageCount() {
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
}
}, {
key: "getSampleAverageTime",
value: function getSampleAverageTime() {
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
}
}, {
key: "getSampleHz",
value: function getSampleHz() {
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0;
}
}, {
key: "getAverageCount",
value: function getAverageCount() {
return this.samples > 0 ? this.count / this.samples : 0;
}
}, {
key: "getAverageTime",
value: function getAverageTime() {
return this.samples > 0 ? this.time / this.samples : 0;
}
}, {
key: "getHz",
value: function getHz() {
return this.time > 0 ? this.samples / (this.time / 1000) : 0;
}
}, {
key: "reset",
value: function reset() {
this.time = 0;
this.count = 0;
this.samples = 0;
this.lastTiming = 0;
this.lastSampleTime = 0;
this.lastSampleCount = 0;
this._count = 0;
this._time = 0;
this._count = 0;
this._samples = 0;
this._startTime = 0;
this._timerPending = false;
return this;
}
}
}, {
key: "_checkSampling",
value: function _checkSampling() {
if (this._samples === this.sampleSize) {
this.lastSampleTime = this._time;
this.lastSampleCount = this._count;
this.count += this._count;
this.time += this._time;
this.samples += this._samples;
this._time = 0;
this._count = 0;
this._samples = 0;
}
}
}]);
return Stat;
}();
}
exports.default = Stat;
//# sourceMappingURL=stat.js.map

@@ -10,2 +10,6 @@ "use strict";

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -15,4 +19,5 @@

class Stats {
constructor(options) {
var Stats = function () {
function Stats(options) {
(0, _classCallCheck2.default)(this, Stats);
(0, _defineProperty2.default)(this, "id", void 0);

@@ -28,70 +33,81 @@ (0, _defineProperty2.default)(this, "stats", {});

get(name) {
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'count';
return this._getOrCreate({
name,
type
});
}
get size() {
return Object.keys(this.stats).length;
}
reset() {
for (const key in this.stats) {
this.stats[key].reset();
(0, _createClass2.default)(Stats, [{
key: "get",
value: function get(name) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'count';
return this._getOrCreate({
name: name,
type: type
});
}
}, {
key: "size",
get: function get() {
return Object.keys(this.stats).length;
}
}, {
key: "reset",
value: function reset() {
for (var key in this.stats) {
this.stats[key].reset();
}
return this;
}
forEach(fn) {
for (const key in this.stats) {
fn(this.stats[key]);
return this;
}
}
}, {
key: "forEach",
value: function forEach(fn) {
for (var key in this.stats) {
fn(this.stats[key]);
}
}
}, {
key: "getTable",
value: function getTable() {
var table = {};
this.forEach(function (stat) {
table[stat.name] = {
time: stat.time || 0,
count: stat.count || 0,
average: stat.getAverageTime() || 0,
hz: stat.getHz() || 0
};
});
return table;
}
}, {
key: "_initializeStats",
value: function _initializeStats() {
var _this = this;
getTable() {
const table = {};
this.forEach(stat => {
table[stat.name] = {
time: stat.time || 0,
count: stat.count || 0,
average: stat.getAverageTime() || 0,
hz: stat.getHz() || 0
};
});
return table;
}
_initializeStats() {
let stats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
stats.forEach(stat => this._getOrCreate(stat));
}
_getOrCreate(stat) {
if (!stat || !stat.name) {
return null;
var stats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
stats.forEach(function (stat) {
return _this._getOrCreate(stat);
});
}
}, {
key: "_getOrCreate",
value: function _getOrCreate(stat) {
if (!stat || !stat.name) {
return null;
}
const {
name,
type
} = stat;
var name = stat.name,
type = stat.type;
if (!this.stats[name]) {
if (stat instanceof _stat.default) {
this.stats[name] = stat;
} else {
this.stats[name] = new _stat.default(name, type);
if (!this.stats[name]) {
if (stat instanceof _stat.default) {
this.stats[name] = stat;
} else {
this.stats[name] = new _stat.default(name, type);
}
}
return this.stats[name];
}
}]);
return Stats;
}();
return this.stats[name];
}
}
exports.default = Stats;
//# sourceMappingURL=stats.js.map

@@ -9,3 +9,3 @@ "use strict";

function getHiResTimestamp() {
let timestamp;
var timestamp;

@@ -15,3 +15,3 @@ if (typeof window !== 'undefined' && window.performance) {

} else if (typeof process !== 'undefined' && process.hrtime) {
const timeParts = process.hrtime();
var timeParts = process.hrtime();
timestamp = timeParts[0] * 1000 + timeParts[1] / 1e6;

@@ -18,0 +18,0 @@ } else {

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "3.5.0-alpha.5",
"version": "3.5.0",
"keywords": [

@@ -29,3 +29,3 @@ "javascript",

},
"gitHead": "8717b64234cc62be48396c4ffbd614e7d7a42cfe"
"gitHead": "101a91ea7a5c71cbe4a46d6c495973a9dd9637ea"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc