VDL Plugin SDK

getOptionNumber

Import from @varavel/vdl-plugin-sdk/utils/options.

function getOptionNumber(
   options, 
   key, 
   defaultValue
): number;

Returns a numeric option or the provided fallback when parsing fails.

Empty, invalid, and non-finite values fall back to the default.

Parameters

ParameterTypeDescription
optionsRecord<string, string> | undefinedPlugin options record.
keystringOption name to read.
defaultValuenumberValue returned when the option is missing or invalid.

Returns

number

The parsed finite number, or the default when parsing fails.

Example

getOptionNumber({ retries: "3" }, "retries", 0);
// returns 3