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.

isBooleanable.js 646B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isBooleanable = void 0;
  4. const isBooleanable = function (value) {
  5. switch (Object.prototype.toString.call(value)) {
  6. case '[object String]':
  7. return [
  8. 'true', 't', 'yes', 'y', 'on', '1',
  9. 'false', 'f', 'no', 'n', 'off', '0'
  10. ].includes(value.trim().toLowerCase());
  11. case '[object Number]':
  12. return [0, 1].includes(value.valueOf());
  13. case '[object Boolean]':
  14. return true;
  15. default:
  16. return false;
  17. }
  18. };
  19. exports.isBooleanable = isBooleanable;