@sports-alliance/sports-lib
Version:
A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc
68 lines (67 loc) • 2.47 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IBIStream = void 0;
var stream_1 = require("./stream");
var IBIStream = /** @class */ (function (_super) {
__extends(IBIStream, _super);
function IBIStream(data) {
var _this = _super.call(this, 'IBI') || this;
if (data) {
_this.data = data;
}
return _this;
}
IBIStream.prototype.getStreamDataByTime = function (startDate, filterNull) {
if (filterNull === void 0) { filterNull = false; }
var time = 0;
return this.data.reduce(function (accu, dataItem, index) {
time += dataItem;
if (filterNull && dataItem === null) {
return accu;
}
accu.push({
time: startDate.getTime() + time,
value: dataItem
});
return accu;
}, []);
};
//
IBIStream.prototype.getStreamDataByDuration = function (offset, filterNull) {
if (filterNull === void 0) { filterNull = false; }
// let data = (new IBIData(<number[]>this.data))
// .lowLimitBPMFilter()
// .lowPassFilter()
// .highLimitBPMFilter().getAsArray();
var data = this.data;
var time = offset || 0;
return data.reduce(function (accu, dataItem, index) {
time += dataItem;
if (filterNull && dataItem === null) {
return accu;
}
accu.push({
time: time,
value: dataItem
});
return accu;
}, []);
};
return IBIStream;
}(stream_1.Stream));
exports.IBIStream = IBIStream;