boolean-checker
v1.2.0
Published
"Boolean Checker" - An npm package for quickly validating true/false/undefined values in JavaScript, enhancing code reliability. Simplify boolean checks for streamlined development.
Downloads
3
Maintainers
Readme
boolean-checker
"Boolean Checker" - Takes a boolean value and returns subsequent strings. i.e
- true: Truthy label
- false: Falsy label
- undefined: '-'
Installation
npm i boolean-checker
Usage
const booleanChecker = require('boolean-checker');
let user = {
can_edit: false
}
// Takes a mandatory 'val' which is a boolean and optional values for true and false cases.
// booleanChecker(val, <truthy label>, <falsy label>)
booleanChecker(user.can_edit, 'Can Edit', 'Cannot Edit')
booleanChecker('laksdfasdf');
//=> Uncaught TypeError: BooleanChecker wants a boolean!
// at booleanChecker (<anonymous>:2:41)
// at <anonymous>:1:1