Move "getNextRotationValue" to lib "HelperFunctions"

This commit is contained in:
schroda
2026-06-02 13:29:36 +02:00
parent d7908a2af0
commit 2964612da1
4 changed files with 18 additions and 25 deletions

View File

@@ -66,3 +66,19 @@ export const extractGraphqlExceptionInfo = (
graphqlStackTrace: stackTrace,
};
};
export const getNextRotationValue = <Value>(
indexOfValue: number,
values: Value[],
isDefaultable?: boolean,
): Value | undefined => {
const nextValueIndex = (indexOfValue + 1) % values.length;
const wasLastValue = nextValueIndex === 0;
const isDefaultNextValue = !!isDefaultable && wasLastValue;
if (isDefaultNextValue) {
return undefined;
}
return values[(indexOfValue + 1) % values.length];
};