UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

21 lines (20 loc) 442 B
import { isNullOrUndefined } from './isNullOrUndefined.js'; /** * Checks if a given value is empty */ export function isEmpty(value) { if (isNullOrUndefined(value)) { return true; } switch (typeof value) { case 'object': { return !Object.keys(value).length; } case 'string': { return !value.trim(); } default: { return false; } } }