frontend


frontend / api/inventory/utils/fieldPickers / pickString

Function: pickString()

pickString(r, k): undefined | string

Defined in: src/api/inventory/utils/fieldPickers.ts:29

Extract string value from record, checking a specific key. Handles both string and number coercion.

Parameters

r

Record<string, unknown>

Record to extract from

k

string

Key to look up

Returns

undefined | string

String value if found, undefined otherwise

Example

const name = pickString(obj, 'name'); // returns string or undefined