• A function that tries to retrieve an environment variable from the process.env object and, if it succeeds, validates that it can be parsed as an integer, and, if so, returns it as a number value. If no variable is found, this function returns undefined.

    Parameters

    • name: string

      The name of the environment variable to look for in process.env.

    Returns undefined | number

    An integer corresponding to the parsed variable's value, if any, else undefined

    Throws

    An Error instance explaining that the variable was present, but that it could not be parsed into a valid integer.

    See

    asInteger

    Note

    Internally, this function uses Number.parseInt to try to convert the string into an integer. That means, for example, that a value like "123_test" will yield "123" instead of failing. In other words, if Number.parseInt returns something other than NaN, this function won't throw.

Generated using TypeDoc