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

copy-concurrentlyfs-write-stream-atomicvuedragdropuploadimagespopsmart-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-clone@ct-note/table@ct-note/warning@ct-note/image@ct-note/inline-code@ct-note/list@ct-note/marker@ct-note/paragraph@ct-note/quote@ct-note/simple-image@ct-note/checklist@ct-note/code@ct-note/delimiter@ct-note/embed@ct-note/header@cube-design/react@blkmarketco/components-library@beldore/react-otp-input@percent/percent-api-hooks@rbc-public/react-selectable-fastgenerator-bootstrap-boilerplate-templatejesusdemojmpr-jpmjamuskalimjameslinenode.js1@simstudio/htmldiffdfeuk-frontenddfeuk-frontend-manualspundlestnenopmoc-iustock-ticker-react-widgettingzi-vuepresstinymce-plugin-toyu-library@artiso-solutions/vue-html-to-paper@arielapaula/components@arielapaula/test@alta-ng-timeago/hiamtanh-alta@beisen/npm@carhoo/widget-dealers@0xcda7a/npm421752593pro@digidem/fs-write-stream-atomicyss-perseusvue-v3-yandex-metrikavinpmverify-img-codevformlmq@farvater/open-pedigree@hproinformatica/functions@icetee/react-recaptcha-v3@elsouza1985/react-org-chart@innodata/vue-v3-ya-metrika@kristoffertonning/vue-laravel-errors@kuinox/testpackagethatnooneshoulduse@kuinox/testpackagethatnooneshoulduseever@krwhitley/neataptic@lazyb/cli@lego-js/tests@inti-ar/evm-chains@meysam213/react-leaflet@mrauhu/npm@ericmcornelius/ease@fabwcie/ckeditor5-preview@jasonssun/npm@jarrydark/editorsimplejs@kirrosh/pts@ikon-x/ckeditor5-custom-build-for-irrosoft@hxyfe/cli@inesfidalgo/forge@react-18-pdf/root@safely-project/safely-ts@sackmanson/quill-image-uploader
1.0.2

7 years ago

1.0.1

7 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

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago