• Casts data to a specific type based on a type identifier.

    Parameters

    • data: any

      The data to cast.

    • dtype: DataModelEnum

      The type identifier.

    Returns
        | SSSResultModel
        | IPRMCResultModel
        | IPRMCResultModelFlat
        | any

    • The data cast to the specified type, or the original data if the type is not recognized.

    dataAsType

    Performs a type assertion on the input data based on the provided dtype. Recognized types are 'SSSResultModel', 'IPRMCResultModel', and 'IPRMCResultModelFlat'. If dtype is unrecognized, returns the data as-is.

    const rawData = { id: 1, value: 'test' };
    const sssData = dataAsType(rawData, DataType.SSSResultModel);
    console.log(sssData); // Treated as SSSResultModel

    const unknownData = dataAsType(rawData, 'unknown' as DataType);
    console.log(unknownData); // Returns rawData unchanged