• JMap.Util.getJmapIdAsIntegerIfPossible

    Converts the passed Id as a numeric JMap Id if possible. This utility function can be used to transform serialized or otherwise stringified JMap Ids that would normally be expressed as integers. For instance, if you extract a JMap Id from a query string, the query param "3" would be returned a an integer (3). If the passed value cannot be converted to a valid JMap numeric Id, it will be returned as-is, if valid. If not valid, an error is thrown.

    Parameters

    • id: any

      The JMap Id to convert

    Returns JId

    Throws

    Error if the passed Id is not a valid JMap Id

    Example

    JMap.Util.getJmapIdAsIntegerIfPossible("1")
    // 1

    JMap.Util.getJmapIdAsIntegerIfPossible("1.4")
    // throw Error

    JMap.Util.getJmapIdAsIntegerIfPossible("f3af01ab-4042-4ccf-be04-33dc96228ce7")
    // "f3af01ab-4042-4ccf-be04-33dc96228ce7"