toBoolean.js 249 B

12345678910
  1. import assertString from './util/assertString';
  2. export default function toBoolean(str, strict) {
  3. assertString(str);
  4. if (strict) {
  5. return str === '1' || /^true$/i.test(str);
  6. }
  7. return str !== '0' && !/^false$/i.test(str) && str !== '';
  8. }