2024-03-18 13:58:05 +01:00
|
|
|
import type { IFeatureStrategyParameters } from 'interfaces/strategy';
|
2022-05-04 15:16:34 +02:00
|
|
|
|
|
|
|
export const parseParameterNumber = (
|
2023-10-02 14:25:46 +02:00
|
|
|
value: IFeatureStrategyParameters[string],
|
2022-05-04 15:16:34 +02:00
|
|
|
): number => {
|
|
|
|
const parsed = Number(parseParameterString(value));
|
|
|
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const parseParameterString = (
|
2023-10-02 14:25:46 +02:00
|
|
|
value: IFeatureStrategyParameters[string],
|
2022-05-04 15:16:34 +02:00
|
|
|
): string => {
|
|
|
|
return String(value ?? '').trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const parseParameterStrings = (
|
2023-10-02 14:25:46 +02:00
|
|
|
value: IFeatureStrategyParameters[string],
|
2022-05-04 15:16:34 +02:00
|
|
|
): string[] => {
|
|
|
|
return parseParameterString(value)
|
|
|
|
.split(',')
|
2023-10-02 14:25:46 +02:00
|
|
|
.map((s) => s.trim())
|
2022-05-04 15:16:34 +02:00
|
|
|
.filter(Boolean);
|
|
|
|
};
|