Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

probe.gl

Package Overview
Dependencies
Maintainers
6
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

probe.gl - npm Package Compare versions

Comparing version 3.0.0-alpha.5 to 3.0.0-alpha.6

dist/es5/lib/stat.js

179

dist/es5/lib/stats.js

@@ -14,6 +14,4 @@ "use strict";

var _hiResTimestamp = _interopRequireDefault(require("../utils/hi-res-timestamp"));
var _stat = _interopRequireDefault(require("./stat"));
var _formatters = require("../utils/formatters");
var Stats = function () {

@@ -24,4 +22,3 @@ function Stats(_ref) {

this.id = id;
this.time = (0, _hiResTimestamp.default)();
this.counters = {};
this.stats = {};
Object.seal(this);

@@ -31,66 +28,12 @@ }

(0, _createClass2.default)(Stats, [{
key: "addCounter",
value: function addCounter(name) {
this._getCounter(name);
return this;
key: "get",
value: function get(name) {
this.stats[name] = this.stats[name] || new _stat.default(name);
return this.stats[name];
}
}, {
key: "bump",
value: function bump(name) {
var counter = this._getCounter(name);
counter.call++;
counter.count++;
return this;
}
}, {
key: "increment",
value: function increment(name, count) {
var counter = this._getCounter(name);
counter.call++;
counter.count += count;
return this;
}
}, {
key: "addTimer",
value: function addTimer(name) {
var timer = this._getCounter(name);
timer.time = 0;
return this;
}
}, {
key: "addTime",
value: function addTime(name, time) {
var timer = this._getCounter(name);
timer.time += time;
timer.count++;
return this;
}
}, {
key: "timeStart",
value: function timeStart(name, subname) {
var timer = this._getCounter(name);
timer._startTime = (0, _hiResTimestamp.default)();
}
}, {
key: "timeEnd",
value: function timeEnd(name, subname) {
var timer = this._getCounter(name);
this.addTime(name, (0, _hiResTimestamp.default)() - timer._startTime);
}
}, {
key: "reset",
value: function reset() {
this.time = (0, _hiResTimestamp.default)();
for (var key in this.counters) {
var counter = this.counters[key];
counter.count = 0;
counter.time = 0;
for (var key in this.stats) {
this.stats[key].reset();
}

@@ -101,106 +44,8 @@

}, {
key: "hasTimeElapsed",
value: function hasTimeElapsed() {
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
return (0, _hiResTimestamp.default)() - this.time > 1000;
}
}, {
key: "getStats",
value: function getStats() {
var deltaTime = ((0, _hiResTimestamp.default)() - this.time) / 1000;
var stats = {};
for (var key in this.counters) {
var counter = this.counters[key];
stats[counter.title] = {
total: counter.count,
fps: Math.round(counter.count / deltaTime)
};
if (counter.time) {
stats[counter.title].totalTime = (0, _formatters.formatTime)(counter.time);
stats[counter.title].avgTime = (0, _formatters.formatTime)(counter.time / counter.count);
}
key: "forEach",
value: function forEach(fn) {
for (var key in this.stats) {
fn(this.stats[key]);
}
return stats;
}
}, {
key: "getStatsTable",
value: function getStatsTable() {
var stats = this.getStats();
for (var key in stats) {
if (stats[key].total === 0) {
delete stats[key];
}
}
return stats;
}
}, {
key: "getStatNames",
value: function getStatNames() {
return Object.keys(this.counters);
}
}, {
key: "get",
value: function get(name) {
var counter = this._getCounter(name);
return counter.count;
}
}, {
key: "getCount",
value: function getCount(name) {
var counter = this._getCounter(name);
return counter.count;
}
}, {
key: "getFPS",
value: function getFPS(name) {
var counter = this._getCounter(name);
var deltaTime = ((0, _hiResTimestamp.default)() - this.time) / 1000;
return Math.round(counter.count / deltaTime);
}
}, {
key: "getTimeString",
value: function getTimeString() {
return "".concat(this.id, ":").concat((0, _formatters.formatTime)(this.time), "(").concat(this.count, ")");
}
}, {
key: "oneSecondPassed",
value: function oneSecondPassed() {
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
return this.hasTimeElapsed(deltaTime);
}
}, {
key: "_getCounter",
value: function _getCounter(name) {
var counter = this.counters[name];
if (!counter) {
counter = {
title: name,
unit: '',
timer: false,
count: 0,
time: 0,
totalTime: 0,
averageTime: 0
};
this.counters[name] = counter;
}
return counter;
}
}, {
key: "_incrementTimer",
value: function _incrementTimer(counter, time, count) {
counter.count += count;
counter.totalTime += time;
counter.averageTime = counter.totalTime / count;
}
}]);

@@ -207,0 +52,0 @@ return Stats;

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

var VERSION = typeof "3.0.0-alpha.5" !== 'undefined' ? "3.0.0-alpha.5" : 'untranspiled source';
var VERSION = typeof "3.0.0-alpha.6" !== 'undefined' ? "3.0.0-alpha.6" : 'untranspiled source';
exports.VERSION = VERSION;

@@ -53,0 +53,0 @@ var isBrowser = (0, _isBrowser.default)();

@@ -1,3 +0,2 @@

import getHiResTimestamp from '../utils/hi-res-timestamp';
import { formatTime } from '../utils/formatters';
import Stat from './stat';
export default class Stats {

@@ -8,63 +7,14 @@ constructor({

this.id = id;
this.time = getHiResTimestamp();
this.counters = {};
this.stats = {};
Object.seal(this);
}
addCounter(name) {
this._getCounter(name);
return this;
get(name) {
this.stats[name] = this.stats[name] || new Stat(name);
return this.stats[name];
}
bump(name) {
const counter = this._getCounter(name);
counter.call++;
counter.count++;
return this;
}
increment(name, count) {
const counter = this._getCounter(name);
counter.call++;
counter.count += count;
return this;
}
addTimer(name) {
const timer = this._getCounter(name);
timer.time = 0;
return this;
}
addTime(name, time) {
const timer = this._getCounter(name);
timer.time += time;
timer.count++;
return this;
}
timeStart(name, subname) {
const timer = this._getCounter(name);
timer._startTime = getHiResTimestamp();
}
timeEnd(name, subname) {
const timer = this._getCounter(name);
this.addTime(name, getHiResTimestamp() - timer._startTime);
}
reset() {
this.time = getHiResTimestamp();
for (const key in this.counters) {
const counter = this.counters[key];
counter.count = 0;
counter.time = 0;
for (const key in this.stats) {
this.stats[key].reset();
}

@@ -75,95 +25,9 @@

hasTimeElapsed(deltaTime = 1000) {
return getHiResTimestamp() - this.time > 1000;
}
getStats() {
const deltaTime = (getHiResTimestamp() - this.time) / 1000;
const stats = {};
for (const key in this.counters) {
const counter = this.counters[key];
stats[counter.title] = {
total: counter.count,
fps: Math.round(counter.count / deltaTime)
};
if (counter.time) {
stats[counter.title].totalTime = formatTime(counter.time);
stats[counter.title].avgTime = formatTime(counter.time / counter.count);
}
forEach(fn) {
for (const key in this.stats) {
fn(this.stats[key]);
}
return stats;
}
getStatsTable() {
const stats = this.getStats();
for (const key in stats) {
if (stats[key].total === 0) {
delete stats[key];
}
}
return stats;
}
getStatNames() {
return Object.keys(this.counters);
}
get(name) {
const counter = this._getCounter(name);
return counter.count;
}
getCount(name) {
const counter = this._getCounter(name);
return counter.count;
}
getFPS(name) {
const counter = this._getCounter(name);
const deltaTime = (getHiResTimestamp() - this.time) / 1000;
return Math.round(counter.count / deltaTime);
}
getTimeString() {
return `${this.id}:${formatTime(this.time)}(${this.count})`;
}
oneSecondPassed(deltaTime = 1000) {
return this.hasTimeElapsed(deltaTime);
}
_getCounter(name) {
let counter = this.counters[name];
if (!counter) {
counter = {
title: name,
unit: '',
timer: false,
count: 0,
time: 0,
totalTime: 0,
averageTime: 0
};
this.counters[name] = counter;
}
return counter;
}
_incrementTimer(counter, time, count) {
counter.count += count;
counter.totalTime += time;
counter.averageTime = counter.totalTime / count;
}
}
//# sourceMappingURL=stats.js.map
import checkIfBrowser from '../env/is-browser';
export { self, window, global, document, process, console } from '../env/globals';
export const VERSION = typeof "3.0.0-alpha.5" !== 'undefined' ? "3.0.0-alpha.5" : 'untranspiled source';
export const VERSION = typeof "3.0.0-alpha.6" !== 'undefined' ? "3.0.0-alpha.6" : 'untranspiled source';
export const isBrowser = checkIfBrowser();
//# sourceMappingURL=globals.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import getHiResTimestamp from '../utils/hi-res-timestamp';
import { formatTime } from '../utils/formatters';
import Stat from './stat';

@@ -13,4 +12,3 @@ var Stats = function () {

this.id = id;
this.time = getHiResTimestamp();
this.counters = {};
this.stats = {};
Object.seal(this);

@@ -20,66 +18,12 @@ }

_createClass(Stats, [{
key: "addCounter",
value: function addCounter(name) {
this._getCounter(name);
return this;
key: "get",
value: function get(name) {
this.stats[name] = this.stats[name] || new Stat(name);
return this.stats[name];
}
}, {
key: "bump",
value: function bump(name) {
var counter = this._getCounter(name);
counter.call++;
counter.count++;
return this;
}
}, {
key: "increment",
value: function increment(name, count) {
var counter = this._getCounter(name);
counter.call++;
counter.count += count;
return this;
}
}, {
key: "addTimer",
value: function addTimer(name) {
var timer = this._getCounter(name);
timer.time = 0;
return this;
}
}, {
key: "addTime",
value: function addTime(name, time) {
var timer = this._getCounter(name);
timer.time += time;
timer.count++;
return this;
}
}, {
key: "timeStart",
value: function timeStart(name, subname) {
var timer = this._getCounter(name);
timer._startTime = getHiResTimestamp();
}
}, {
key: "timeEnd",
value: function timeEnd(name, subname) {
var timer = this._getCounter(name);
this.addTime(name, getHiResTimestamp() - timer._startTime);
}
}, {
key: "reset",
value: function reset() {
this.time = getHiResTimestamp();
for (var key in this.counters) {
var counter = this.counters[key];
counter.count = 0;
counter.time = 0;
for (var key in this.stats) {
this.stats[key].reset();
}

@@ -90,106 +34,8 @@

}, {
key: "hasTimeElapsed",
value: function hasTimeElapsed() {
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
return getHiResTimestamp() - this.time > 1000;
}
}, {
key: "getStats",
value: function getStats() {
var deltaTime = (getHiResTimestamp() - this.time) / 1000;
var stats = {};
for (var key in this.counters) {
var counter = this.counters[key];
stats[counter.title] = {
total: counter.count,
fps: Math.round(counter.count / deltaTime)
};
if (counter.time) {
stats[counter.title].totalTime = formatTime(counter.time);
stats[counter.title].avgTime = formatTime(counter.time / counter.count);
}
key: "forEach",
value: function forEach(fn) {
for (var key in this.stats) {
fn(this.stats[key]);
}
return stats;
}
}, {
key: "getStatsTable",
value: function getStatsTable() {
var stats = this.getStats();
for (var key in stats) {
if (stats[key].total === 0) {
delete stats[key];
}
}
return stats;
}
}, {
key: "getStatNames",
value: function getStatNames() {
return Object.keys(this.counters);
}
}, {
key: "get",
value: function get(name) {
var counter = this._getCounter(name);
return counter.count;
}
}, {
key: "getCount",
value: function getCount(name) {
var counter = this._getCounter(name);
return counter.count;
}
}, {
key: "getFPS",
value: function getFPS(name) {
var counter = this._getCounter(name);
var deltaTime = (getHiResTimestamp() - this.time) / 1000;
return Math.round(counter.count / deltaTime);
}
}, {
key: "getTimeString",
value: function getTimeString() {
return "".concat(this.id, ":").concat(formatTime(this.time), "(").concat(this.count, ")");
}
}, {
key: "oneSecondPassed",
value: function oneSecondPassed() {
var deltaTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
return this.hasTimeElapsed(deltaTime);
}
}, {
key: "_getCounter",
value: function _getCounter(name) {
var counter = this.counters[name];
if (!counter) {
counter = {
title: name,
unit: '',
timer: false,
count: 0,
time: 0,
totalTime: 0,
averageTime: 0
};
this.counters[name] = counter;
}
return counter;
}
}, {
key: "_incrementTimer",
value: function _incrementTimer(counter, time, count) {
counter.count += count;
counter.totalTime += time;
counter.averageTime = counter.totalTime / count;
}
}]);

@@ -196,0 +42,0 @@

import checkIfBrowser from '../env/is-browser';
export { self, window, global, document, process, console } from '../env/globals';
export var VERSION = typeof "3.0.0-alpha.5" !== 'undefined' ? "3.0.0-alpha.5" : 'untranspiled source';
export var VERSION = typeof "3.0.0-alpha.6" !== 'undefined' ? "3.0.0-alpha.6" : 'untranspiled source';
export var isBrowser = checkIfBrowser();
//# sourceMappingURL=globals.js.map

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

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

@@ -8,0 +8,0 @@ "javascript",

@@ -1,159 +0,30 @@

import getHiResTimestamp from '../utils/hi-res-timestamp';
import {formatTime} from '../utils/formatters';
import Stat from './stat';
// const MAX_FPS = 70;
export default class Stats {
constructor({id}) {
this.id = id;
this.time = getHiResTimestamp();
this.counters = {};
this.stats = {};
Object.seal(this);
}
// Initialize a new counter
addCounter(name) {
this._getCounter(name);
return this;
// Acquire a stat. Create if it doesn't exist.
get(name) {
this.stats[name] = this.stats[name] || new Stat(name);
return this.stats[name];
}
// Call to bump a counter (+1)
bump(name) {
const counter = this._getCounter(name);
counter.call++;
counter.count++;
return this;
}
// Call to bump a counter
increment(name, count) {
const counter = this._getCounter(name);
counter.call++;
counter.count += count;
return this;
}
addTimer(name) {
const timer = this._getCounter(name);
timer.time = 0;
return this;
}
addTime(name, time) {
const timer = this._getCounter(name);
timer.time += time;
timer.count++;
return this;
}
timeStart(name, subname) {
const timer = this._getCounter(name);
timer._startTime = getHiResTimestamp();
}
timeEnd(name, subname) {
const timer = this._getCounter(name);
this.addTime(name, getHiResTimestamp() - timer._startTime);
}
// Reset all timers
// Reset all stats
reset() {
this.time = getHiResTimestamp();
for (const key in this.counters) {
const counter = this.counters[key];
counter.count = 0;
counter.time = 0;
for (const key in this.stats) {
this.stats[key].reset();
}
return this;
}
// ACCESSORS
hasTimeElapsed(deltaTime = 1000) {
return getHiResTimestamp() - this.time > 1000;
}
getStats() {
const deltaTime = (getHiResTimestamp() - this.time) / 1000;
const stats = {};
for (const key in this.counters) {
const counter = this.counters[key];
stats[counter.title] = {
total: counter.count,
fps: Math.round(counter.count / deltaTime)
};
if (counter.time) {
stats[counter.title].totalTime = formatTime(counter.time);
stats[counter.title].avgTime = formatTime(counter.time / counter.count);
}
forEach(fn) {
for (const key in this.stats) {
fn(this.stats[key]);
}
return stats;
}
// Return stats in a "table format" suitable for console.table() or Log.table()
getStatsTable() {
const stats = this.getStats();
for (const key in stats) {
if (stats[key].total === 0) {
delete stats[key];
}
}
return stats;
}
// Returns the names of all registered stats, enables iteration
getStatNames() {
return Object.keys(this.counters);
}
get(name) {
const counter = this._getCounter(name);
return counter.count;
}
getCount(name) {
const counter = this._getCounter(name);
return counter.count;
}
getFPS(name) {
const counter = this._getCounter(name);
const deltaTime = (getHiResTimestamp() - this.time) / 1000;
return Math.round(counter.count / deltaTime);
}
// DEPRECATED METHODS
getTimeString() {
return `${this.id}:${formatTime(this.time)}(${this.count})`;
}
oneSecondPassed(deltaTime = 1000) {
return this.hasTimeElapsed(deltaTime);
}
// PRIVATE METHODS
_getCounter(name) {
let counter = this.counters[name];
if (!counter) {
counter = {
title: name,
unit: '',
timer: false,
count: 0,
time: 0,
totalTime: 0,
averageTime: 0
};
this.counters[name] = counter;
}
return counter;
}
_incrementTimer(counter, time, count) {
counter.count += count;
counter.totalTime += time;
counter.averageTime = counter.totalTime / count;
}
}

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