quantified-self-lib
Advanced tools
Comparing version 3.3.7 to 3.3.8
@@ -11,3 +11,3 @@ import { DataInterface, UnitSystem } from './data.interface'; | ||
setValue(value: string | number | boolean | string[]): this; | ||
getValue(): string | number | boolean | string[]; | ||
getValue(formatForDataType?: string): string | number | boolean | string[]; | ||
getDisplayValue(): number | string | string[]; | ||
@@ -14,0 +14,0 @@ getType(): string; |
@@ -5,3 +5,3 @@ import { SerializableClassInterface } from '../serializable/serializable.class.interface'; | ||
setValue(value: number | string | string[]): this; | ||
getValue(): number | string | boolean | string[]; | ||
getValue(formatForDataType?: string): number | string | boolean | string[]; | ||
getDisplayValue(): number | string | boolean | string[]; | ||
@@ -8,0 +8,0 @@ getType(): string; |
@@ -15,3 +15,3 @@ "use strict"; | ||
}; | ||
Data.prototype.getValue = function () { | ||
Data.prototype.getValue = function (formatForDataType) { | ||
return this.value; | ||
@@ -18,0 +18,0 @@ }; |
@@ -5,3 +5,3 @@ import { DataBare } from './data.bare'; | ||
constructor(value: number); | ||
getValue(): number; | ||
getValue(formatForDataType?: string): number; | ||
} |
@@ -20,11 +20,7 @@ "use strict"; | ||
function DataNumber(value) { | ||
var _this = this; | ||
if (typeof value !== 'number') { | ||
throw new Error('Only numbers are allowed for numeric data'); | ||
} | ||
_this = _super.call(this, value) || this; | ||
var _this = _super.call(this, value) || this; | ||
_this.value = value; | ||
return _this; | ||
} | ||
DataNumber.prototype.getValue = function () { | ||
DataNumber.prototype.getValue = function (formatForDataType) { | ||
return this.value; | ||
@@ -31,0 +27,0 @@ }; |
@@ -7,2 +7,3 @@ import { DataDuration } from './data.duration'; | ||
getDisplayUnit(): string; | ||
getValue(formatForDataType?: string): number; | ||
} | ||
@@ -13,2 +14,3 @@ export declare class DataPaceMinutesPerMile extends DataPace { | ||
static unit: string; | ||
getValue(formatForDataType?: string): number; | ||
} |
@@ -17,2 +17,3 @@ "use strict"; | ||
var data_duration_1 = require("./data.duration"); | ||
var helpers_1 = require("../events/utilities/helpers"); | ||
var DataPace = /** @class */ (function (_super) { | ||
@@ -41,2 +42,10 @@ __extends(DataPace, _super); | ||
}; | ||
DataPace.prototype.getValue = function (formatForDataType) { | ||
switch (formatForDataType) { | ||
case DataPaceMinutesPerMile.type: | ||
return helpers_1.convertPaceToPaceInMinutesPerMile(this.value); | ||
default: | ||
return _super.prototype.getValue.call(this, formatForDataType); | ||
} | ||
}; | ||
DataPace.type = 'Pace'; | ||
@@ -52,2 +61,8 @@ DataPace.unit = 'min/km'; | ||
} | ||
DataPaceMinutesPerMile.prototype.getValue = function (formatForDataType) { | ||
if (formatForDataType) { | ||
throw new Error("Not implemented"); | ||
} | ||
return _super.prototype.getValue.call(this, formatForDataType); | ||
}; | ||
DataPaceMinutesPerMile.type = 'Pace in minutes per mile'; | ||
@@ -54,0 +69,0 @@ DataPaceMinutesPerMile.displayType = DataPace.type; |
@@ -6,2 +6,3 @@ import { DataNumber } from './data.number'; | ||
getDisplayValue(): string; | ||
getValue(formatForDataType?: string): number; | ||
} | ||
@@ -8,0 +9,0 @@ export declare class DataSpeedKilometersPerHour extends DataSpeed { |
@@ -17,2 +17,5 @@ "use strict"; | ||
var data_number_1 = require("./data.number"); | ||
var helpers_1 = require("../events/utilities/helpers"); | ||
var data_pace_1 = require("./data.pace"); | ||
var data_swim_pace_1 = require("./data.swim-pace"); | ||
var DataSpeed = /** @class */ (function (_super) { | ||
@@ -26,2 +29,29 @@ __extends(DataSpeed, _super); | ||
}; | ||
DataSpeed.prototype.getValue = function (formatForDataType) { | ||
switch (formatForDataType) { | ||
// Speed cases conversions | ||
case DataSpeedKilometersPerHour.type: | ||
return helpers_1.convertSpeedToSpeedInKilometersPerHour(this.value); | ||
case DataSpeedMilesPerHour.type: | ||
return helpers_1.convertSpeedToSpeedInMilesPerHour(this.value); | ||
case DataSpeedFeetPerSecond.type: | ||
return helpers_1.convertSpeedToSpeedInFeetPerSecond(this.value); | ||
case DataSpeedMetersPerMinute.type: | ||
return helpers_1.convertSpeedToSpeedInMetersPerMinute(this.value); | ||
case DataSpeedFeetPerMinute.type: | ||
return helpers_1.convertSpeedToSpeedInFeetPerMinute(this.value); | ||
// Pace | ||
case data_pace_1.DataPace.type: | ||
return helpers_1.convertSpeedToPace(this.value); | ||
case data_pace_1.DataPaceMinutesPerMile.type: | ||
return helpers_1.convertPaceToPaceInMinutesPerMile(helpers_1.convertSpeedToPace(this.value)); | ||
// Swim pace | ||
case data_swim_pace_1.DataSwimPace.type: | ||
return helpers_1.convertSpeedToSwimPace(this.value); | ||
case data_swim_pace_1.DataSwimPaceMinutesPer100Yard.type: | ||
return helpers_1.convertSwimPaceToSwimPacePer100Yard(helpers_1.convertSpeedToSwimPace(this.value)); | ||
default: | ||
return _super.prototype.getValue.call(this, formatForDataType); | ||
} | ||
}; | ||
DataSpeed.type = 'Speed'; | ||
@@ -28,0 +58,0 @@ DataSpeed.unit = 'm/s'; |
@@ -20,4 +20,7 @@ import { EventInterface } from './event.interface'; | ||
getLastActivity(): ActivityInterface; | ||
getActivityTypesAsString(): string; | ||
getDeviceNamesAsString(): string; | ||
private sortActivities; | ||
private getUniqueStringWithMultiplier; | ||
toJSON(): EventJSONInterface; | ||
} |
@@ -16,2 +16,4 @@ import { SerializableClassInterface } from '../serializable/serializable.class.interface'; | ||
getActivities(): ActivityInterface[]; | ||
getActivityTypesAsString(): string; | ||
getDeviceNamesAsString(): string; | ||
clearActivities(): void; | ||
@@ -18,0 +20,0 @@ getFirstActivity(): ActivityInterface; |
@@ -18,2 +18,5 @@ "use strict"; | ||
var privacy_class_interface_1 = require("../privacy/privacy.class.interface"); | ||
var activity_types_1 = require("../activities/activity.types"); | ||
var data_activity_types_1 = require("../data/data.activity-types"); | ||
var data_device_names_1 = require("../data/data.device-names"); | ||
var Event = /** @class */ (function (_super) { | ||
@@ -64,2 +67,18 @@ __extends(Event, _super); | ||
}; | ||
Event.prototype.getActivityTypesAsString = function () { | ||
var activityTypesStat = this.getStat(data_activity_types_1.DataActivityTypes.type); | ||
if (!activityTypesStat) { | ||
throw new Error("Event has no activity types"); | ||
} | ||
return activityTypesStat.getValue().length > 1 ? | ||
"" + this.getUniqueStringWithMultiplier(activityTypesStat.getValue().map(function (activityType) { return activity_types_1.ActivityTypes[activityType]; })) | ||
: activity_types_1.ActivityTypes[activityTypesStat.getDisplayValue()]; | ||
}; | ||
Event.prototype.getDeviceNamesAsString = function () { | ||
var deviceNamesStat = this.getStat(data_device_names_1.DataDeviceNames.type); | ||
if (!deviceNamesStat) { | ||
throw new Error("Event has no device names"); | ||
} | ||
return "" + this.getUniqueStringWithMultiplier(deviceNamesStat.getValue()); | ||
}; | ||
Event.prototype.sortActivities = function () { | ||
@@ -70,2 +89,22 @@ this.activities.sort(function (activityA, activityB) { | ||
}; | ||
Event.prototype.getUniqueStringWithMultiplier = function (arrayOfStrings) { | ||
var uniqueObject = arrayOfStrings.reduce(function (uniqueObj, type, index) { | ||
if (!uniqueObj[type]) { | ||
uniqueObj[type] = 1; | ||
} | ||
else { | ||
uniqueObj[type] += 1; | ||
} | ||
return uniqueObj; | ||
}, {}); | ||
return Object.keys(uniqueObject).reduce(function (uniqueArray, key, index, object) { | ||
if (uniqueObject[key] === 1) { | ||
uniqueArray.push(key); | ||
} | ||
else { | ||
uniqueArray.push(uniqueObject[key] + 'x ' + key); | ||
} | ||
return uniqueArray; | ||
}, []).join(', '); | ||
}; | ||
Event.prototype.toJSON = function () { | ||
@@ -72,0 +111,0 @@ var stats = {}; |
@@ -115,3 +115,3 @@ "use strict"; | ||
}); | ||
var event = new event_1.Event("Merged at " + (new Date()).toISOString(), activities[0].startDate, activities[activities.length - 1].endDate, privacy_class_interface_1.Privacy.Private, "Merge event ", true); | ||
var event = new event_1.Event("Merged at " + (new Date()).toISOString(), activities[0].startDate, activities[activities.length - 1].endDate, privacy_class_interface_1.Privacy.Private, "A merge of 2 or more activities ", true); | ||
event.addActivities(activities); | ||
@@ -118,0 +118,0 @@ this.generateStatsForAll(event); |
@@ -25,4 +25,3 @@ import { UserDashboardChartSettingsInterface } from './user.dashboard.chart.settings.interface'; | ||
lastYear = 7, | ||
custom = 8, | ||
all = 9 | ||
custom = 8 | ||
} |
@@ -14,3 +14,3 @@ "use strict"; | ||
DateRanges[DateRanges["custom"] = 8] = "custom"; | ||
DateRanges[DateRanges["all"] = 9] = "all"; | ||
// all, | ||
})(DateRanges = exports.DateRanges || (exports.DateRanges = {})); |
{ | ||
"name": "quantified-self-lib", | ||
"version": "3.3.7", | ||
"version": "3.3.8", | ||
"description": "A Library to for processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
704051
11590