Files
asciidisco.com/build/node_modules/to-boolean-x/index.js
2023-08-01 13:49:46 +02:00

28 lines
691 B
JavaScript

/**
* @file Converts argument to a value of type Boolean.
* @version 1.0.1
* @author Xotic750 <Xotic750@gmail.com>
* @copyright Xotic750
* @license {@link <https://opensource.org/licenses/MIT> MIT}
* @module to-boolean-x
*/
'use strict';
/**
* The abstract operation ToBoolean converts argument to a value of type Boolean.
*
* @param {*} value - The value to be converted.
* @returns {boolean} 'true' if value is truthy; otherwise 'false'.
* @example
* var toBoolean = require('to-boolean-x');
*
* toBoolean(null); // false
* toBoolean(''); // false
* toBoolean(1); // true
* toBoolean('0'); // true
*/
module.exports = function toBoolean(value) {
return !!value;
};