1.1.0 • Published 10 years ago
value-when v1.1.0
value-when 
Return a value when a condition passes, otherwise return undefined
Install
$ npm install --save value-whenUsage
var when = require('value-when')
when(true, 'value')
//=> 'value'
when(false, 'value')
//=> undefinedOr use the functional API:
var when = require('value-when/fn')
when(true, function () {
return 'value'
})
//=> 'value'
when(false, function () {
return 'value'
})
//=> undefinedAPI
when(condition, value) -> value / undefined
condition
Required
Type: any
A value to check for truthiness/falsiness.
value
Type: any
A value to return when the condition passes. When using the functional API, value should be a function to be called to return the output value.
License
MIT © Ben Drucker