• Home
Name Date Size #Lines LOC

..--

test/12-May-2024-4638

.npmignoreD12-May-202413 21

LICENSED12-May-20241.1 KiB2117

README.mdD12-May-2024675 4130

index.coffeeD12-May-2024803 2520

index.jsD12-May-20241 KiB5038

package.jsonD12-May-20241.3 KiB5655

README.md

1# iferr
2
3Higher-order functions for easier error handling.
4
5`if (err) return cb(err);` be gone!
6
7## Install
8```bash
9npm install iferr
10```
11
12## Use
13
14### JavaScript example
15```js
16var iferr = require('iferr');
17
18function get_friends_count(id, cb) {
19  User.load_user(id, iferr(cb, function(user) {
20    user.load_friends(iferr(cb, function(friends) {
21      cb(null, friends.length);
22    }));
23  }));
24}
25```
26
27### CoffeeScript example
28```coffee
29iferr = require 'iferr'
30
31get_friends_count = (id, cb) ->
32  User.load_user id, iferr cb, (user) ->
33    user.load_friends iferr cb, (friends) ->
34      cb null, friends.length
35```
36
37(TODO: document tiferr, throwerr and printerr)
38
39## License
40MIT
41