Sindbad~EG File Manager

Current Path : /home/infinitibizsol/.trash/node_modules.2/underscore.string/
Upload File :
Current File : /home/infinitibizsol/.trash/node_modules.2/underscore.string/toBoolean.js

var trim = require('./trim');

function boolMatch(s, matchers) {
  var i, matcher, down = s.toLowerCase();
  matchers = [].concat(matchers);
  for (i = 0; i < matchers.length; i += 1) {
    matcher = matchers[i];
    if (!matcher) continue;
    if (matcher.test && matcher.test(s)) return true;
    if (matcher.toLowerCase() === down) return true;
  }
}

module.exports = function toBoolean(str, trueValues, falseValues) {
  if (typeof str === 'number') str = '' + str;
  if (typeof str !== 'string') return !!str;
  str = trim(str);
  if (boolMatch(str, trueValues || ['true', '1'])) return true;
  if (boolMatch(str, falseValues || ['false', '0'])) return false;
};

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists