VDL Plugin SDK

getOptionArray

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

function getOptionArray(
   options, 
   key, 
   defaultValue?, 
   separator?
): string[];

Returns a string array option from a separator-delimited value.

Empty items are removed and each entry is trimmed.

Missing values return the provided default.

Parameters

ParameterTypeDefault valueDescription
optionsRecord<string, string> | undefinedundefinedPlugin options record.
keystringundefinedOption name to read.
defaultValue?string[][]Value returned when the option is missing.
separator?string","Delimiter used to split the raw string.

Returns

string[]

A trimmed array of non-empty entries, an empty array for blank values, or the default when the key is missing.

Example

// For options: { "features": "feature1, feature2, feature3" }
getOptionArray(options, "features", [], ",")
// returns ["feature1", "feature2", "feature3"]