• 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 a float value, 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

    A float 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 float.

    See

    asFloat

    Note

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

Generated using TypeDoc