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.

boolean.ts 405B

1234567891011121314151617
  1. const boolean = function (value: any): boolean {
  2. switch (Object.prototype.toString.call(value)) {
  3. case '[object String]':
  4. return [ 'true', 't', 'yes', 'y', 'on', '1' ].includes(value.trim().toLowerCase());
  5. case '[object Number]':
  6. return value.valueOf() === 1;
  7. case '[object Boolean]':
  8. return value.valueOf();
  9. default:
  10. return false;
  11. }
  12. };
  13. export { boolean };