# otherwise

> Executes fallback behavior if a function was unsuccessful.

Latest version **2.0.1** (published 2020-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install otherwise
pnpm add otherwise
yarn add otherwise
bun add otherwise
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-11-12 |
| First published | 2018-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 3 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fr. John Lamansky |
| Maintainers | lamansky |
| Keywords | else, fallback |

## Links

- npm: https://www.npmjs.com/package/otherwise
- Repository: https://github.com/lamansky/otherwise
- Homepage: https://github.com/lamansky/otherwise#readme
- Issues: https://github.com/lamansky/otherwise/issues
- npm.io page: https://npm.io/package/otherwise

## Dependencies (3)

- [arrify](https://npm.io/package/arrify.md) ^1.0.1
- [errate](https://npm.io/package/errate.md) ^1.1.0
- [roadblock](https://npm.io/package/roadblock.md) ^1.1.0

## Recent versions

- 2.0.1 (latest) — 2020-11-12
- 2.0.0 — 2018-11-03
- 1.2.0 — 2018-11-03
- 1.1.0 — 2018-08-17
- 1.0.0 — 2018-05-22

## README

# otherwise

Executes fallback behavior if a function was unsuccessful. Intended for use in modules that use option object arguments.

## Installation

Requires [Node.js](https://nodejs.org/) 6.0.0 or above.

```bash
npm i otherwise
```

## API

The module exports a single function.

### Parameters

1. Optional: Object argument:
    * `elseCall` (function): If provided, this function will be called with at least one argument: a function that will invoke the other fallbacks. (If `args` are specified, they will be provided as subsequent arguments.) If the function argument is not called, then `elseThrow` and `elseReturn` will not be taken into consideration, and the return value of the `elseCall` function will be forwarded.
    * `elseThrow` (Error or string): An error to be thrown. A string will be wrapped in an `Error` object automatically.
    * `elseReturn` (any): A value to return if `elseThrow` is omitted.
2. Optional: Object argument:
    * `defaultErrorClass` (Class): An Error class in which to wrap `elseThrow` if it is a string.
    * `args` (array): An array of arguments that should be passed on to `elseCall` if provided.

### Return Value

Returns the return value of `elseCall` (if provided) or returns `elseReturn`.

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