first
Get the first item from a list
62 bytes
Usage
Given an array of items return the first item or a default value if no items exists.
import * as import _
_ from 'radashi'
const const gods: string[]
gods = ['ra', 'loki', 'zeus']
const const first: string | undefined
first = import _
_.first<string[], undefined>(array: string[], defaultValue?: undefined): string | undefinedexport first
Get the first item in an array or a default value.
first(const gods: string[]
gods) // => 'ra'const const firstDefault: "vishnu"
firstDefault = import _
_.first<readonly [], "vishnu">(array: readonly [], defaultValue?: "vishnu" | undefined): "vishnu"export first
Get the first item in an array or a default value.
first([], 'vishnu') // => 'vishnu'