Socket
Socket
Sign inDemoInstall

iferr

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

5

index.js

@@ -7,2 +7,5 @@ // Generated by CoffeeScript 1.7.1

iferr = function(fail, succ) {
if (succ == null) {
succ = noop;
}
return function() {

@@ -37,3 +40,3 @@ var a, err;

throwerr = function(succ) {
return iferr(throwr, succ || noop);
return iferr(throwr, succ);
};

@@ -40,0 +43,0 @@

2

package.json
{
"name": "iferr",
"version": "0.1.1",
"version": "0.1.2",
"description": "Higher-order functions for easier error handling",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,4 +0,40 @@

iferr
=====
# iferr
Higher-order functions for easier error handling
Higher-order functions for easier error handling.
`if (err) return cb(err);` be gone!
## Install
```bash
npm install iferr
```
## Use
### JavaScript 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 and throwerr)
## License
MIT

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc