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

    iferr

Higher-order functions for easier error handling


Version published
Weekly downloads
4.8M
decreased by-11.59%
Maintainers
1
Install size
6.04 kB
Created
Weekly downloads
 

Readme

Source

iferr

Higher-order functions for easier error handling.

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

Install

npm install iferr

Use

JavaScript example

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

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

Keywords

FAQs

Last updated on 01 Dec 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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