hevy-shared 1.0.597 → 1.0.599
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/utils.d.ts +8 -0
- package/built/utils.js +27 -1
- package/package.json +1 -1
package/built/utils.d.ts
CHANGED
|
@@ -199,6 +199,14 @@ type GenerateUserGroupError = 'invalid-number-of-groups' | 'invalid-uuid' | 'uui
|
|
|
199
199
|
* `(userId, numGroups)` pair, or an error, inside a Result<T> object
|
|
200
200
|
*/
|
|
201
201
|
export declare const generateUserGroup: (userId: string, numGroups: number) => Result<number, GenerateUserGroupError>;
|
|
202
|
+
/**
|
|
203
|
+
* Get the user group value for a given user id and number of groups.
|
|
204
|
+
* @param userId a v4 UUID; _must_ be v4 to ensure random distribution
|
|
205
|
+
* @param numGroups number of possible groups, from 2 to 2^32
|
|
206
|
+
* @returns User group value (A, B, C, etc.), or undefined if the user id is not a v4 UUID
|
|
207
|
+
* or if an error occurs.
|
|
208
|
+
*/
|
|
209
|
+
export declare const generateUserGroupValue: (userId: string, numGroups: 2 | 3) => "A" | "B" | "C" | undefined;
|
|
202
210
|
/**
|
|
203
211
|
* @example
|
|
204
212
|
* isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2') // true
|
package/built/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = 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.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
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.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Doesn't matter what you throw in the function it'll
|
|
6
6
|
* always return a number. Non number values will return
|
|
@@ -542,6 +542,32 @@ const generateUserGroup = (userId, numGroups) => {
|
|
|
542
542
|
};
|
|
543
543
|
};
|
|
544
544
|
exports.generateUserGroup = generateUserGroup;
|
|
545
|
+
/**
|
|
546
|
+
* Get the user group value for a given user id and number of groups.
|
|
547
|
+
* @param userId a v4 UUID; _must_ be v4 to ensure random distribution
|
|
548
|
+
* @param numGroups number of possible groups, from 2 to 2^32
|
|
549
|
+
* @returns User group value (A, B, C, etc.), or undefined if the user id is not a v4 UUID
|
|
550
|
+
* or if an error occurs.
|
|
551
|
+
*/
|
|
552
|
+
const generateUserGroupValue = (userId, numGroups) => {
|
|
553
|
+
const group = (0, exports.generateUserGroup)(userId, numGroups);
|
|
554
|
+
if (group.isSuccess) {
|
|
555
|
+
switch (group.value) {
|
|
556
|
+
case 0:
|
|
557
|
+
return 'A';
|
|
558
|
+
case 1:
|
|
559
|
+
return 'B';
|
|
560
|
+
case 2:
|
|
561
|
+
return 'C';
|
|
562
|
+
default:
|
|
563
|
+
return undefined;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
exports.generateUserGroupValue = generateUserGroupValue;
|
|
545
571
|
/**
|
|
546
572
|
* @example
|
|
547
573
|
* isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2') // true
|