InventoryTrack/node_modules/boolean/lib/boolean.ts
2022-11-02 22:16:03 -04:00

18 lines
405 B
TypeScript

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 };