fluent-switch
v1.0.2
Published
Switch reloaded
Downloads
3
Readme
FluentSwitch
Better way to do switching.
Installation
npm i fluent-switch
Usage
No fallback
FluentSwitch
.createFrom(error)
.case(e => e instanceof TimeoutError, e => log.error('timeout', e))
.case(e => e instanceof ConnectionError, () => e => log.error('connection', e))
.execute()
With fallback
FluentSwitch
.createFrom(error)
.case(e => e instanceof TimeoutError, e => log.error('timeout', e))
.case(e => e instanceof ConnectionError, () => e => log.error('connection', e))
.else(e => log.error('Unknown error', e))
.execute()