hevy-shared 1.0.763 → 1.0.764
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/units.d.ts +5 -0
- package/built/units.js +7 -1
- package/built/utils.d.ts +1 -16
- package/built/utils.js +1 -46
- package/package.json +1 -1
package/built/units.d.ts
CHANGED
|
@@ -16,3 +16,8 @@ export declare const roundedCmToFtIn: (cm: number) => {
|
|
|
16
16
|
in: number;
|
|
17
17
|
};
|
|
18
18
|
export declare const exactFtInToCm: (ftIn: FtIn) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Round kilo- to deci- (e.g. kilograms/kg to decigrams/dg). Used for comparing
|
|
21
|
+
* weight values in kg which may have originated in lbs.
|
|
22
|
+
*/
|
|
23
|
+
export declare const roundKtoD: (value: number) => number;
|
package/built/units.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exactFtInToCm = exports.roundedCmToFtIn = exports.exactMetersToMiles = exports.exactMilesToMeters = exports.exactCmtoInch = exports.exactInchtoCm = exports.exactKgtoLbs = exports.exactLbsToKg = exports.METERS_IN_MILE = exports.CM_IN_INCH = exports.POUNDS_IN_KG = void 0;
|
|
3
|
+
exports.roundKtoD = exports.exactFtInToCm = exports.roundedCmToFtIn = exports.exactMetersToMiles = exports.exactMilesToMeters = exports.exactCmtoInch = exports.exactInchtoCm = exports.exactKgtoLbs = exports.exactLbsToKg = exports.METERS_IN_MILE = exports.CM_IN_INCH = exports.POUNDS_IN_KG = void 0;
|
|
4
4
|
exports.POUNDS_IN_KG = 2.20462;
|
|
5
5
|
exports.CM_IN_INCH = 2.54;
|
|
6
6
|
exports.METERS_IN_MILE = 1609.34;
|
|
@@ -45,3 +45,9 @@ const exactFtInToCm = (ftIn) => {
|
|
|
45
45
|
return Math.round((0, exports.exactInchtoCm)(totalInches));
|
|
46
46
|
};
|
|
47
47
|
exports.exactFtInToCm = exactFtInToCm;
|
|
48
|
+
/**
|
|
49
|
+
* Round kilo- to deci- (e.g. kilograms/kg to decigrams/dg). Used for comparing
|
|
50
|
+
* weight values in kg which may have originated in lbs.
|
|
51
|
+
*/
|
|
52
|
+
const roundKtoD = (value) => Math.round(value / 10000);
|
|
53
|
+
exports.roundKtoD = roundKtoD;
|
package/built/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseExerciseTemplate, FormatAtText,
|
|
1
|
+
import { BaseExerciseTemplate, FormatAtText, Result, StrengthLevel, UserExerciseSet } from '.';
|
|
2
2
|
/**
|
|
3
3
|
* Doesn't matter what you throw in the function it'll
|
|
4
4
|
* always return a number. Non number values will return
|
|
@@ -226,19 +226,4 @@ export declare const isVersionAGreaterOrEqualToVersionB: (versionA: string, vers
|
|
|
226
226
|
export declare const splitAtUsernamesAndLinks: (text: string) => FormatAtText[];
|
|
227
227
|
export declare const validateYoutubeUrl: (url: string) => boolean;
|
|
228
228
|
export declare const getYoutubeVideoId: (url: string) => string | undefined;
|
|
229
|
-
declare const _comparisonOperators: readonly ["<", ">", "!=", "=", "<=", ">="];
|
|
230
|
-
declare const _setValueContexts: readonly ["pr"];
|
|
231
|
-
declare const _setValueUnitTypes: readonly ["weight"];
|
|
232
|
-
type ComparisonOperator = Lookup<typeof _comparisonOperators>;
|
|
233
|
-
type SetValueContext = Lookup<typeof _setValueContexts>;
|
|
234
|
-
type SetValueUnitType = Lookup<typeof _setValueUnitTypes>;
|
|
235
|
-
/**
|
|
236
|
-
* Compares two floating point numbers to the precision given by the context in
|
|
237
|
-
* which they occur. Used to standardise calculations throughout the app, and
|
|
238
|
-
* produce consistent behaviour between the frontend and the backend.
|
|
239
|
-
*/
|
|
240
|
-
export declare const compareSetValues: (lhs: number, operator: ComparisonOperator, rhs: number, options: {
|
|
241
|
-
context: SetValueContext;
|
|
242
|
-
unitType: SetValueUnitType;
|
|
243
|
-
}) => boolean;
|
|
244
229
|
export {};
|
package/built/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const _1 = require(".");
|
|
3
|
+
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.secondsToClockParts = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
5
4
|
/**
|
|
6
5
|
* Doesn't matter what you throw in the function it'll
|
|
7
6
|
* always return a number. Non number values will return
|
|
@@ -674,47 +673,3 @@ const getYoutubeVideoId = (url) => {
|
|
|
674
673
|
return match && match[1] && match[1].length === 11 ? match[1] : undefined;
|
|
675
674
|
};
|
|
676
675
|
exports.getYoutubeVideoId = getYoutubeVideoId;
|
|
677
|
-
const _comparisonOperators = [
|
|
678
|
-
'<', // significantly less than
|
|
679
|
-
'>', // significantly greater than
|
|
680
|
-
'!=', // significantly different from
|
|
681
|
-
'=', // approximately equal to
|
|
682
|
-
'<=', // not significantly greater than
|
|
683
|
-
'>=', // not significantly less than
|
|
684
|
-
];
|
|
685
|
-
const _setValueContexts = ['pr'];
|
|
686
|
-
const _setValueUnitTypes = ['weight'];
|
|
687
|
-
/**
|
|
688
|
-
* For each combination of parameters, ignore any difference within the given
|
|
689
|
-
* range when comparing two values.
|
|
690
|
-
*/
|
|
691
|
-
const _setValueRoundingPrecisionMap = {
|
|
692
|
-
weight: { pr: 0.0075 },
|
|
693
|
-
};
|
|
694
|
-
/**
|
|
695
|
-
* Compares two floating point numbers to the precision given by the context in
|
|
696
|
-
* which they occur. Used to standardise calculations throughout the app, and
|
|
697
|
-
* produce consistent behaviour between the frontend and the backend.
|
|
698
|
-
*/
|
|
699
|
-
const compareSetValues = (lhs, operator, rhs, options) => {
|
|
700
|
-
const { context, unitType } = options;
|
|
701
|
-
const difference = Math.abs(lhs - rhs);
|
|
702
|
-
const isApproximatelyEqual = difference <= _setValueRoundingPrecisionMap[unitType][context];
|
|
703
|
-
switch (operator) {
|
|
704
|
-
case '<':
|
|
705
|
-
return lhs < rhs && !isApproximatelyEqual;
|
|
706
|
-
case '>':
|
|
707
|
-
return lhs > rhs && !isApproximatelyEqual;
|
|
708
|
-
case '!=':
|
|
709
|
-
return !isApproximatelyEqual;
|
|
710
|
-
case '=':
|
|
711
|
-
return isApproximatelyEqual;
|
|
712
|
-
case '<=':
|
|
713
|
-
return lhs < rhs || isApproximatelyEqual;
|
|
714
|
-
case '>=':
|
|
715
|
-
return lhs < rhs || isApproximatelyEqual;
|
|
716
|
-
default:
|
|
717
|
-
throw (0, _1.exhaustiveTypeException)(operator);
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
exports.compareSetValues = compareSetValues;
|