You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
405 B
18 lines
405 B
const boolean = function (value: any): boolean {
|
|
switch (Object.prototype.toString.call(value)) {
|
|
case '[object String]':
|
|
return [ 'true', 't', 'yes', 'y', 'on', '1' ].includes(value.trim().toLowerCase());
|
|
|
|
case '[object Number]':
|
|
return value.valueOf() === 1;
|
|
|
|
case '[object Boolean]':
|
|
return value.valueOf();
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
|
|
export { boolean };
|