Throws if the specified argument is empty/nullable.
npm i throw-if-arg-empty
import { throwIfEmpty } from 'throw-if-arg-empty';
function foo(name) {
throwIfEmpty(name, 'name');
}
foo();
// throws: Error: The argument "name" cannot be empty
// Throws if argument is `undefined` or `null`.
function throwIfEmptyStrict(argument: unknown, name: string): void;
// Throws if argument is `undefined`, `null` or an empty array.
function throwIfEmpty(argument: unknown, name: string): void;
// Throws if argument is falsy.
function throwIfFalsyStrict(argument: unknown, name: string): void;
// Throws if argument is falsy or an empty array.
function throwIfFalsy(argument: unknown, name: string): void;