# if

> Conditional branching for node.js

Latest version **2.0.0** (published 2015-01-25) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2015-01-25 |
| First published | 2015-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Bell |
| Maintainers | mappum |

## Links

- npm: https://www.npmjs.com/package/if
- npm.io page: https://npm.io/package/if

## Recent versions

- 2.0.0 (latest) — 2015-01-25
- 1.0.0 — 2015-01-25

## README

# if
Conditional branching for Javascript

### Installation
```
npm install if
```

### Usage
If the condition is truthy, the handler function passed to `Then` will be called.
```js
If(condition).Then(handler);
```

A handler can be passed to the `Else` method, which will be called if the condition is not truthy.
```js
If(condition).Then(handler)
  .Else(handler);
```

To evaluate more conditions, call `If` after `Else`.
```js
If(condition).Then(handler)
  .Else().If(condition).Then(handler)
  .Else().If(condition).Then(handler);
```

### Example
```js
If(isRobot()).Then(function(){
    console.log('beep');
  }).Else().If(isHuman()).Then(function(){
    console.log('boop');
  }).Else(function(){
    console.log('?')
  });
```

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