# iferr

> Higher-order functions for easier error handling

Latest version **1.0.2** (published 2018-06-18) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-06-18 |
| First published | 2014-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/iferr) |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Nadav Ivgi |
| Maintainers | nadav |
| Keywords | error, errors |

## Links

- npm: https://www.npmjs.com/package/iferr
- Repository: https://github.com/shesek/iferr
- Issues: https://github.com/shesek/iferr/issues
- npm.io page: https://npm.io/package/iferr

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-06-18
- 1.0.1 — 2018-06-14
- 1.0.0 — 2017-11-25
- 0.1.5 — 2014-12-02
- 0.1.4 — 2014-12-02
- 0.1.3 — 2014-12-01
- 0.1.2 — 2014-04-26
- 0.1.1 — 2014-04-26
- 0.1.0 — 2014-04-11

## README

# iferr

Higher-order functions for easier error handling.

`if (err) return cb(err);` be gone!

## Install
```bash
npm install iferr
```

## Use

### JavaScript/ES6 example
```js
var iferr = require('iferr');

function get_friends_count(id, cb) {
  User.load_user(id, iferr(cb, user =>
    user.load_friends(iferr(cb, friends =>
      cb(null, friends.length)
    ))
  ))
}
```

### JavaScript/ES5 example
```js
var iferr = require('iferr');

function get_friends_count(id, cb) {
  User.load_user(id, iferr(cb, function(user) {
    user.load_friends(iferr(cb, function(friends) {
      cb(null, friends.length)
    }))
  }))
}
```

### CoffeeScript example
```coffee
iferr = require 'iferr'

get_friends_count = (id, cb) ->
  User.load_user id, iferr cb, (user) ->
    user.load_friends iferr cb, (friends) ->
      cb null, friends.length
```

(TODO: document tiferr, throwerr and printerr)

## License
MIT

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