Home > @gglib/utils > getOption

getOption() function

Gets a value by key from an options object

Signature:

export declare function getOption<T, K extends keyof T>(options: T, key: K, fallback?: T[K]): T[K];

Parameters

Parameter Type Description
options T The options object
key K The key to access
fallback T[K] The fallback value

Returns:

T[K]

the value behind the key. If the key is missing fallback is returned.