Skip to main content
Version: v0.0.2

Function: getString()

getString(obj, key): string | undefined

Read a string property from an untrusted object, or undefined if absent/not a string.

Parameters

obj

unknown

The source object (may be any unknown).

key

string

The property name to read.

Returns

string | undefined

The string value, or undefined when the key is missing or not a string.

Example

import { getString } from "@cosyte/terminology";

getString({ url: "http://loinc.org" }, "url"); // => "http://loinc.org"