# throw-if-arg-empty

> Throws if the specified argument is empty/nullable

Latest version **3.1.0** (published 2021-05-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install throw-if-arg-empty
pnpm add throw-if-arg-empty
yarn add throw-if-arg-empty
bun add throw-if-arg-empty
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2021-05-15 |
| First published | 2018-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mgenware |
| Maintainers | mgenware |

## Links

- npm: https://www.npmjs.com/package/throw-if-arg-empty
- Repository: https://github.com/mgenware/throw-if-arg-empty
- Issues: https://github.com/mgenware/throw-if-arg-empty/issues
- npm.io page: https://npm.io/package/throw-if-arg-empty

## Recent versions

- 3.1.0 (latest) — 2021-05-15
- 3.0.0 — 2021-05-05
- 2.2.1 — 2019-12-24
- 2.2.0 — 2019-11-16
- 2.1.0 — 2019-09-07
- 2.0.2 — 2019-06-10
- 2.0.1 — 2019-03-20
- 2.0.0 — 2019-03-20
- 1.0.1 — 2018-10-21

## README

# throw-if-arg-empty

[![Build Status](https://github.com/mgenware/throw-if-arg-empty/workflows/Build/badge.svg)](https://github.com/mgenware/throw-if-arg-empty/actions)
[![npm version](https://img.shields.io/npm/v/throw-if-arg-empty.svg?style=flat-square)](https://npmjs.com/package/throw-if-arg-empty)
[![Node.js Version](http://img.shields.io/node/v/throw-if-arg-empty.svg?style=flat-square)](https://nodejs.org/en/)

Throws if the specified argument is empty/nullable.

### Installation

```sh
yarn add throw-if-arg-empty
```

### Example

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

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

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

### APIs

```typescript
// 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;
```

---
_Source: https://npm.io/package/throw-if-arg-empty · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
