@polargold/pg-frontend-core
    Preparing search index...

    Class TypeCastUtils

    Casts a raw string (e.g. a query param or form field) into a typed value - number, boolean, null/undefined, or an array of strings.

    Ported from luv-autoq-frontend's copy, which fixed a regex state-leak bug still present in bws-checkout-service-spa's copy: hasLettersPattern and whiteSpacePattern used to carry the global (g) regex flag. A regex with g keeps .lastIndex state between .test() calls, so mixed alphanumeric input (e.g. "1a", "12a34") was inconsistently miscast to a number or NaN depending on how many times the pattern had already been tested. Neither pattern needs g here - both are always tested from the start of the string - so the flag is simply dropped.

    Index
    hasLettersPattern: RegExp = ...
    isArrayPattern: RegExp = ...
    isFloatPatternComma: RegExp = ...
    isFloatPatternDot: RegExp = ...
    isNumberPattern: RegExp = ...
    value: string
    whiteSpacePattern: RegExp = ...
    • get stringToArray(): string | number | boolean | string[] | null | undefined

      Returns string | number | boolean | string[] | null | undefined