3.1.0 • Published 4 years ago

throw-if-arg-empty v3.1.0

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

throw-if-arg-empty

Build Status npm version Node.js Version

Throws if the specified argument is empty/nullable.

Installation

yarn add throw-if-arg-empty

Example

import { throwIfEmpty } from 'throw-if-arg-empty';

function foo(name) {
  throwIfEmpty(name, 'name');
}

foo();
// throws: Error: The argument "name" cannot be empty

APIs

// 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;
3.1.0

4 years ago

3.0.0

4 years ago

2.2.1

5 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

7 years ago