foop
Version:
interfaces that describe their intentions.
30 lines (28 loc) • 650 B
JavaScript
/**
* toBoolean
* toBool
*
* 5.0.0-beta.6
* cast
*
* {*} x anything
* {boolean} !!x
*
* { https://tc39.github.io/ecma262/#sec-toboolean emca-toboolean}
* { https://github.com/chriso/validator.js/blob/master/src/lib/toBoolean.js validator-toboolean}
* { validator-toboolean}
* { emca-toboolean}
*
*
*
* toBoolean(0) //=> false
* toBoolean(1) //=> true
* toBoolean(true) //=> true
* toBoolean(false) //=> false
* toBoolean({} //=> true
*
*/
const toBoolean = function(x) {
return !!x
}
module.exports = toBoolean