# @bemoje/assert-args

> Assert that the passed arguments are defined.

Latest version **1.0.2** (published 2020-05-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @bemoje/assert-args
pnpm add @bemoje/assert-args
yarn add @bemoje/assert-args
bun add @bemoje/assert-args
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-20 |
| First published | 2020-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Benjamin M. Jensen |
| Maintainers | bemoje |
| Keywords | assert, passed, arguments, defined, assertargs, args, array, argument, undefined |

## Links

- npm: https://www.npmjs.com/package/@bemoje/assert-args
- Repository: https://github.com/bemoje/bemoje-assert-args
- Homepage: https://github.com/bemoje/bemoje-assert-args#readme
- Issues: https://github.com/bemoje/bemoje-assert-args/issues
- npm.io page: https://npm.io/package/@bemoje/assert-args

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^4.0.0
- [@bemoje/is-args-defined](https://npm.io/package/@bemoje/is-args-defined.md) ^1.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-20
- 1.0.1 — 2020-04-30
- 1.0.0 — 2020-04-25

## README

# @bemoje/assert-args

Assert that the passed arguments are defined.

#### Version

<span><a href="https://npmjs.org/@bemoje/assert-args" title="View this project on NPM"><img src="https://img.shields.io/npm/v/@bemoje/assert-args" alt="NPM version" /></a></span>

#### Travis CI

<span><a href="https://npmjs.org/@bemoje/assert-args" title="View this project on NPM"><img src="https://travis-ci.org/bemoje/bemoje-assert-args.svg?branch=master" alt="dependencies" /></a></span>

#### Dependencies

<span><a href="https://npmjs.org/@bemoje/assert-args" title="View this project on NPM"><img src="https://david-dm.org/bemoje/bemoje-assert-args.svg" alt="dependencies" /></a></span>

#### Stats

<span><a href="https://npmjs.org/@bemoje/assert-args" title="View this project on NPM"><img src="https://img.shields.io/npm/dt/@bemoje/assert-args" alt="NPM downloads" /></a></span>
<span><a href="https://github.com/bemoje/bemoje-assert-args/fork" title="Fork this project"><img src="https://img.shields.io/github/forks/bemoje/bemoje-assert-args" alt="Forks" /></a></span>

#### Donate

<span><a href="https://www.buymeacoffee.com/bemoje" title="Donate to this project using Buy Me A Beer"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?label=Buy me a beer!" alt="Buy Me A Beer donate button" /></a></span>
<span><a href="https://paypal.me/forstaaloen" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg?label=PayPal" alt="PayPal donate button" /></a></span>

## Installation

```sh
npm install @bemoje/assert-args
npm install --save @bemoje/assert-args
npm install --save-dev @bemoje/assert-args
```

## Usage

```javascript

import assertArgs from '@bemoje/assert-args'

/**
 * Adds a and b and throws Error if any parameters are missing
 */
function add(a, b) {
  assertArgs(a, b)
  return a + b
}

/**
 * Calls the callback and returns true if the callback throws an error and false otherwise.
 */
function didItThrow(callback) {
  try {
    callback()
    return false
  } catch (e) {
    return true
  }
}

didItThrow(() => add(1, 4))
//=> false

didItThrow(() => add(1))
//=> true

```


## Tests
Uses *Jest* to test module functionality. Run tests to get coverage details.

```bash
npm run test
```

## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [assertArgs][1]

    -   [Parameters][2]

## assertArgs

Assert that the passed arguments are defined.

##### Parameters

-   `args` **...any** arguments array

-   Throws **[Error][3]** If any passed argument is undefined.

Returns **void** 

[1]: #assertargs

[2]: #parameters

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

---
_Source: https://npm.io/package/@bemoje/assert-args · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
