1.0.2 • Published 7 years ago

iferr v1.0.2

Weekly downloads
11,291,428
License
MIT
Repository
github
Last release
7 years ago

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

fs-write-stream-atomiccopy-concurrentlyvuedragdropuploadimagespopsmart-common-authkilli8n-react-native-fast-image@cashremit/cr-streamline-iconsbb-chat@frxf/frxf@fundefund/funde_ckgql_din_mod@l1nyanm1ng/react-picture-viewer@meicloud/clijs4cytoscape@infinitebrahmanuniverse/nolb-if@saaspe/components@everything-registry/sub-chunk-1895test-carosello-campusvue-button-test1webchewedmasterwuchuansupercluster-googlemaps-adapter-clonessticky-scroll-catchtestapasvelte-component-libtextfield-samplevue-compmentvue-dev-clonegenerator-bootstrap-boilerplate-templatejesusdemojmpr-jpmjamuskalimjameslinenode.js1hubot-budahot-zone-vuehodlhexo-renderer-webpack4grid-component-react-ex-1guruwayguruway.jshelp-widgethexo-theme-essencelitepie-datepicker-gabem2m-chartjs-plugin-crosshairmakara-buildermakara-writer-amdl2forlernalabnote@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@udooku/react-image-comparison-slider@tonysusi/vapid@thedoctor0/vuex-shared-mutations@vitali_shcherbina/styled-lib@zalastax/nolb-if@zh0st/evm-chains@zebracompany/f_editora_react_reflux_demoaaaaaserverb2x-utilsasync-waiterarifbudixzap-vue-captchaappcharge-checkoutgentle-fsfrdrk-js-semaphoreforminput-ui-libfn-lib-examplefork-react-ffmpegeasyplayer-mydust-makara-helperseditorjs-alerticonseffect-protofastlion-picture-viewerfirst-app-lyfuciflowable-bpmn-modelercampus-carosellocampus1campus2campus3campus4car-cmp-2caropcarop2carop3carop4carosello-campus-opacitacarosello-tribuscarosello-tribus-2connex_ram00nezconnex-kakilangcdoakcase-gg-editorckeditor-5-imi-1ckeditor5-build-custom-strapickeditor5-custom-build-for-irrosoftckeditor5-strapi-msgckeditor5-custom-symmetreckeditor5-build-yektaconstrux-makara-amdifyconstrux-makara-browserify
1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago