2023-03-20 17:26:21 +01:00
|
|
|
import { parseGuessedValueType } from './parseGuessedValueType'
|
|
|
|
import { parseVariables } from './parseVariables'
|
2024-03-18 16:09:19 +01:00
|
|
|
import { Variable } from './types'
|
2023-03-20 17:26:21 +01:00
|
|
|
|
|
|
|
export const parseVariableNumber =
|
|
|
|
(variables: Variable[]) =>
|
|
|
|
(input: number | `{{${string}}}` | undefined): number | undefined => {
|
|
|
|
if (typeof input === 'number' || input === undefined) return input
|
|
|
|
const parsedInput = parseGuessedValueType(parseVariables(variables)(input))
|
|
|
|
if (typeof parsedInput !== 'number') return undefined
|
|
|
|
return parsedInput
|
|
|
|
}
|