1.0.2 • Published 6 years ago

iferr v1.0.2

Weekly downloads
11,291,428
License
MIT
Repository
github
Last release
6 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-1895labnotel2forlernalitepie-datepicker-gabehodlhelp-widgethot-zone-vuehexo-renderer-webpack4hexo-theme-essencehubot-budajamuskalimjesusdemojmpr-jpmmyui5librarychenmyui5librarymobong-search-dropdownmulti-tenant-dust-makara-helpersmiracle-webpack-tree-shakingmyreuselibrarynaver-npmm2m-chartjs-plugin-crosshairmakara-buildermakara-writer-amdmiguelcostero-ng2-toastynot-bundled-npmnois-react-toastnpm5vnpm-msys2npm-prognull-session-npmnpmcnst-cli@simstudio/htmldiffjameslinenode.js1editorjs-alerticonseffect-protoeasyplayer-mydust-makara-helpersgrid-component-react-ex-1guruwayguruway.jsfirst-app-lyfucifastlion-picture-viewerflowable-bpmn-modelergenerator-bootstrap-boilerplate-templatefrdrk-js-semaphoregentle-fsfork-react-ffmpegfn-lib-exampleforminput-ui-libnpm5qa_hddprova-2-caroselloprova-cmpprova-cpm-2prova-cpm-3prova-cpm-4pzmtestqxf2006hf0216pub-keystoreqyx-hmtldiffqlobber-pgreact-form-component-libraryreact-misc-toolboxparvan_componentsparvan_reactjs_componentsreact-redux-demo1react-picky-with-clearreact-otp-input-uptdsaberssequelcomponentserver-liuxinru@ericmcornelius/ease@elsouza1985/react-org-chart@hproinformatica/functions@farvater/open-pedigree@ikon-x/ckeditor5-custom-build-for-irrosoft@jasonssun/npm@jarrydark/editorsimplejs@icetee/react-recaptcha-v3vformlmqvinpmverify-img-codevue-compmentvue-dev-clone
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago