Skip to content

harish2704/catch-if.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')} )

About

A catIf syntactic sugar for Javscrip promises

Resources

License

Stars

Watchers

Forks

Packages

No packages published