@kozderka/pattern-matching
v0.0.1
Published
Pattern matching
Downloads
74
Readme
Pattern matching
Introduction
Package provides functionality for pattern matching.
Installation
npm install @kozderka/pattern-matching
Documentation
Table of Contents
PatternBuilder
Type: Object
match
Parameters
value
V
Examples
import match from '@kozderka/pattern-matching'
const result = match(1)
.where((value) => value === 1, (value) => '2')
.where(2, (value) => '2')
.where('text', (value) => 'text')
.where(true, (value) => 'true')
.where({a: 1, b:2}, (value) => 'object')
.otherwise((value) => 'otherwise')
.run()
Returns PatternBuilder