toBoolean.js 546 B

123456789101112131415161718192021
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = toBoolean;
  6. var _assertString = require('./util/assertString');
  7. var _assertString2 = _interopRequireDefault(_assertString);
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. function toBoolean(str, strict) {
  10. (0, _assertString2.default)(str);
  11. if (strict) {
  12. return str === '1' || str === 'true';
  13. }
  14. return str !== '0' && str !== 'false' && str !== '';
  15. }
  16. module.exports = exports['default'];