Mezza 🎯
An object switch-case. Selects the appropriate case from the object with variants. Core part of mezzanine
npm install --save mezza
Usage
{ /* Some function that returns a list of users */} const cases = Array && valuelength > 1 Array && valuelength === 1 Array && valuelength === 0 const actions = 'Find ' + listlength + ' users' 'Find one user: ' + list0 'Nothing found' 'Oops, something going wrong!' //Optional default case { const found = const resultText = return resultText}
Method is curried by default
const printText = // => Found one user: username // => 'Oops, something going wrong!'
Try this example in browser
License
The project is released under the Mit License