uncertain-bool
Flow control for indeterminate booleans as plain JS objects
Use case: Your API returns booleans, but sometimes a value is unknown. You want to have a clea structure for determining unknown values, as plain JS objects.
Install
$ npm install --save uncertain-bool
Usage
var Uncertain = var value = // => 'uncertain' // => 'uncertain' // => 'uncertain' Uncertain // => trueUncertain // => falseUncertain // => falseUncertain // => false // => true // => true // => true // => false // => 'uncertain'
API
Uncertain(...values) -> boolean|'uncertain'
If all of the values are null or undefined, returns 'uncertain'.
Otherwise, returns the truthy or falsy version of those values, with the exception of 'false'
returned as false
.
Uncertain.is(value) -> boolean
Returns whether the value is 'uncertain'.
License
MIT © Andrew Joslin