UNPKG

@iotile/iotile-cloud

Version:

A typescript library for interfacing with the IOTile Cloud API

34 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PADDING = "000000"; var Stats = /** @class */ (function () { function Stats(data) { if (data === void 0) { data = {}; } this.count = 0; this.min = data.min; this.max = data.max; this.count = data.count; this.sum = data.sum; this.avg = data.avg; this.intervalDays = data.interval_days; } Stats.prototype._formatNumber = function (value, decimals) { var decimalDeparator = "."; var result; var _a = value.toString().split(decimalDeparator), integer = _a[0], _b = _a[1], fraction = _b === void 0 ? "" : _b; fraction = decimals > 0 ? decimalDeparator + (fraction + PADDING).substring(0, decimals) : ""; result = integer + fraction; return result; }; Stats.prototype.getFormattedAvg = function () { if (this.avg) { return this._formatNumber(this.avg, 3); } return ""; }; return Stats; }()); exports.Stats = Stats; //# sourceMappingURL=stats.js.map