API
@agape/util

isPresent Function

Checks if a value is present (not empty).

API

function isPresent<T>(  value: undefined |  | T): 

isPresent

unknown

Checks if a value is present (not empty).

@paramvalue:  undefined | "null" | T
The value to check for presence
@returnsunknown

Description

Checks if a value is present (not empty).

A value is considered present if it is NOT:

  • undefined
  • null
  • An empty string ''

Usage

isPresent(undefined); // false
isPresent(null); // false
isPresent(''); // false
isPresent('hello'); // true
isPresent(0); // true
isPresent(false); // true
isPresent([]); // true