Skip to content

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

Parameter Type Description
options Record\<string, string> | undefined Plugin options record.
key string Option name to read.
defaultValue number Value 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