Skip to content

maximilian-krauss/fluent-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FluentSwitch

Build Status

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()

About

Everything is better if its fluent

Resources

Stars

Watchers

Forks

Packages

No packages published