Brief-Switch
- The shortest syntax for functional "switch"-style comparison.
- The fastest possible function designed to replace built-in "switch" statement.
- A list of cases may be generated and mutated in the runtime.
Installation
npm i -S brief-switch
Example
const switchB = ; { /*smth.*/ } { return 5; } const cases = 'foo' 'bar' 1 2 3 fn1 fn2 'default';const result = ; // 5
Explanation
Every odd value in the "cases" array is a test. Every even value is a result. The last value is an analog of built-in "switch" statement's "default".