Get Main Field

Retrieves the main field from an item object based on a predefined list of labels to highlight.

CategoryObjects
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    getMainField({ name: 'John Doe', value: 'johndoe123' })

    Output:

    { key: 'name', value: 'John Doe' }

Return

Returns an object containing the key and value of the main field.

Type: object

Props

NameTypeDefaultRequiredDescription
itemRecord<string, any>nullYesThe item object from which to extract the main field.

Notes

The function searches for the first label in the `DEFAULT_KEYS` array that exists in the item object. If no label is found, the first key-value pair from the item object is returned instead.

Tags

  • object
  • field
  • main
  • label
  • extraction

Related