2019-10-31 09:03:22 +07:00
|
|
|
/**
|
|
|
|
*
|
2019-10-31 09:40:11 +07:00
|
|
|
* Booler can convert any value to Boolean type.
|
2019-10-31 09:03:22 +07:00
|
|
|
*
|
2019-10-31 09:40:11 +07:00
|
|
|
* @author Samob Chea <sombochea@cubetiqs.com>
|
2019-10-31 09:03:22 +07:00
|
|
|
* @param {*} val Value to parse.
|
|
|
|
*/
|
|
|
|
const booler = (val) => {
|
2019-10-31 09:45:34 +07:00
|
|
|
// transform to string lower case.
|
|
|
|
val = val + "".toLowerCase();
|
2019-10-31 09:03:22 +07:00
|
|
|
return val == 't' || val == 'true' || val == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export module within function name `booler`.
|
|
|
|
module.exports = booler;
|