catch-if

0.0.1 • Public • Published

catch-if.js

A catIf syntactic sugar for Javscrip promises

Installation

npm i catch-if -S

Usage

Step:1 - Monkeypatch your Promise class

require('catch-if')(Promise);

Step:2 - Use catchIf method

Promise.reject( new TypeError() )
.catchIf( TypeError, function handler(err){ console.log('TypeError handled')} )
.catchIf( RangeError, function handler(err){ console.log('RangeError handled')} )

/catch-if/

    Package Sidebar

    Install

    npm i catch-if

    Weekly Downloads

    2

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • harish2704