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
Maintainers
1
Weekly downloads
5,220,160
decreased by-10.08%

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/ES6 example

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

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 18 Jun 2018

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