Skip to main content
Module

x/nameable/deps.ts>first

Cross-check whether it can be used as a package name or domain name
Latest
variable first
import { first } from "https://deno.land/x/nameable@v1.1.0-beta.4/deps.ts";

Returns the first element of the given list or string.

Examples

Example 1

// String
first('') // ''
first('hello') // 'h'

Example 2

// Array
first('hello', 'new', 'world') // 'hello'
first([]) // undefined
first(['one', 2, 3, 4]) // 'one'

type

<T extends readonly unknown[] | string>(val: T) => First<T>