0.1.0 • Published 7 years ago

vybor v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

vybor - выбор

Build Status npm version

Function to choose comparing with a value. Like switch, but you don't need an IIFE.

npm add vybor
import выбор from 'vybor'

console.log(выбор('jupiter')(
  'mars', 'red',
  'jupiter', 'green',
  'saturn', 'purple'
)) // => 'green'

If you want to set a fallback option if none match, you can just set a fallback value as a second argument of the first function:

выбор('pluto', 'probably not a planet')(
  'mars', 'red',
  'jupiter', 'green',
  'saturn', 'purple'
) // => 'probably not a planet'

Mind that this means that if the selected is explicitly set to be undefined, it will return the fallback option:

выбор('mars', 'probably not a planet')(
  'mars', undefined,
  'jupiter', 'green',
  'saturn', 'purple'
) // => 'probably not a planet'

See also

License

See License