ternary switch statement (also converts undefined values to blank string automatically)
332422
function (bool, valueIfTrue, valueIfFalse) {
        return bool ? (valueIfTrue == undefined ? '' : valueIfTrue) : (valueIfFalse == undefined ? '' : valueIfFalse);
    }
344231
function(_string) {
    if ('undefined' == typeof _string) {
      return null;
    }
    else if ('string' != typeof _string) {
      throw new Error('Wrong parameter type');
    }

    var str = _string.reverse();
    var ret = 0;

    for (var i = 0; i <= (str.length - 1); i++) {
      ret = ret + this.index.indexOf(str.substr(i, 1)) * (this.bcpow(this.index.length, (str.length - 1) - i));
    }

    return ret;
  }
1307485
function string_to_boolean (string) {

  // It's a boolean already, no need to parse
  if (typeof string === 'boolean') { return string; }

  // Check for bad values
  if (string === undefined) { return false; }
  if (string === null)      { return false; }

  if (typeof string === 'string') { string = string.toLowerCase(); }

  switch (string) {
    case 'true':
    case 1:
    case '1':
    case 'yes':
      return true;
    case 'false':
    case 0:
    case '0':
    case 'no':
    case 'null':
    case null:
      return false;
    default:
      //return Boolean(string);
      return false;
  }

}
926278
function checkType(type, key, value, options) {
  options = options || {};

  if (value != undefined) {
    if (options.isArray)
      return checkArray(type, key, value);

    var checker = checkType[type];
    if (checker) return checker(key, value);

    console.warn("Could not check " + key + ", unknown type " + type);
    //    throw TypeError("Could not check "+key+", unknown type "+type);
  } else if (options.required)
    throw SyntaxError(key + " param is required");

}
633391
function (argv) {
    if (typeof argv == "string") {
      argv = argv.split(" ");
    }
    var opts = {}, params = [];
    argv.forEach(function(arg) {
      var m = arg.match(/^-{0,2}(.+?[^\\])=(.*)$/);
      if (m == null) { // No match
        arg = unescape(arg, '=');
        try {
          arg = JSON.parse(arg);
        } catch (e) {} // don't care
        params.push(arg);
        return;
      }
      var key = unescape(m[1], "="), value = m[2];
      try {
        // Parses out numbers, booleans, arrays, objects, etc, but if the param was given as "field=" then nullify
        if (value == "") value = null;
        else value = JSON.parse(value);
      } catch (e) {} // don't care

      val(opts, key, value);
    });

    return { opts: opts, params: params };
  }
250928
function(content) {
                // Convert bad values into empty strings
                var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN';
                return '' + (isInvalid ? '' : content);
            }
964818
def p_switch_statement(self, p):
        """"""
        cases = []
        default = None
        # iterate over return values from case_block
        for item in p[5]:
            if isinstance(item, ast.Default):
                default = item
            elif isinstance(item, list):
                cases.extend(item)

        p[0] = ast.Switch(expr=p[3], cases=cases, default=default)
872685
function(deselectValues, triggerOnChange) {
            if(!$.isArray(deselectValues)) {
                deselectValues = [deselectValues];
            }

            for (var i = 0; i < deselectValues.length; i++) {
                var value = deselectValues[i];

                if (value === null || value === undefined) {
                    continue;
                }

                var $option = this.getOptionByValue(value);
                var $checkbox = this.getInputByValue(value);

                if($option === undefined || $checkbox === undefined) {
                    continue;
                }

                if (this.options.selectedClass) {
                    $checkbox.closest('li')
                        .removeClass(this.options.selectedClass);
                }

                $checkbox.prop('checked', false);
                $option.prop('selected', false);

                if (triggerOnChange) {
                    this.options.onChange($option, false);
                }
            }

            this.updateButtonText();
            this.updateSelectAll();
        }
766208
function /*9.2.9 */$$core$$GetOption (options, property, type, values, fallback) {
        var
            // 1. Let value be the result of calling the [[Get]] internal method of
            //    options with argument property.
            value = options[property];

        // 2. If value is not undefined, then
        if (value !== undefined) {
            // a. Assert: type is "boolean" or "string".
            // b. If type is "boolean", then let value be ToBoolean(value).
            // c. If type is "string", then let value be ToString(value).
            value = type === 'boolean' ? Boolean(value)
                      : (type === 'string' ? String(value) : value);

            // d. If values is not undefined, then
            if (values !== undefined) {
                // i. If values does not contain an element equal to value, then throw a
                //    RangeError exception.
                if ($$core$$arrIndexOf.call(values, value) === -1)
                    throw new RangeError("'" + value + "' is not an allowed value for `" + property +'`');
            }

            // e. Return value.
            return value;
        }
        // Else return fallback.
        return fallback;
    }
717361
function(args) {
            args = this.trim(args, '&\?#');

            var parts = args.split('&');
            var output = {};

            var key;
            var value;
            var equalsSegments;
            var lim = parts.length;
            for (var i=0,l=lim; i<l; i++) {
                equalsSegments = parts[i].split('=');
                key = decodeURIComponent(equalsSegments.shift());
                value = equalsSegments.join("=");
                output[key] = decodeURIComponent(value);
            }
            return output;
        }
608249
static TernaryValue getImpureBooleanValue(Node n) {
    switch (n.getToken()) {
      case ASSIGN:
      case COMMA:
        // For ASSIGN and COMMA the value is the value of the RHS.
        return getImpureBooleanValue(n.getLastChild());
      case NOT:
        TernaryValue value = getImpureBooleanValue(n.getLastChild());
        return value.not();
      case AND: {
        TernaryValue lhs = getImpureBooleanValue(n.getFirstChild());
        TernaryValue rhs = getImpureBooleanValue(n.getLastChild());
        return lhs.and(rhs);
      }
      case OR:  {
        TernaryValue lhs = getImpureBooleanValue(n.getFirstChild());
        TernaryValue rhs = getImpureBooleanValue(n.getLastChild());
        return lhs.or(rhs);
      }
      case HOOK:  {
        TernaryValue trueValue = getImpureBooleanValue(
            n.getSecondChild());
        TernaryValue falseValue = getImpureBooleanValue(n.getLastChild());
        if (trueValue.equals(falseValue)) {
          return trueValue;
        } else {
          return TernaryValue.UNKNOWN;
        }
      }
      case NEW:
      case ARRAYLIT:
      case OBJECTLIT:
        // ignoring side-effects
        return TernaryValue.TRUE;

      case VOID:
        return TernaryValue.FALSE;

      default:
        return getPureBooleanValue(n);
    }
  }
387622
function ( value ) {
            var result = false;
    
            switch ( this.type(value) ) {
                case 'Object':
                    result = true;
                    for ( var key in value ) {
                        result = false;
                        break;
                    }
                    break;
                case 'Array':
                    result = value.length === 0;
                    break;
                case 'Null':
                    result = true;
                    break;
                case 'Undefined':
                    result = true;
                    break;
                case 'String':
                    result = '' === value;
                    break;
            }
    
            return result;
        }
264274
function parseQueryStringValues(str, options) {
    var obj = {};
    var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
    var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
    var parts = cleanStr.split(options.delimiter, limit);
    var skipIndex = -1; // Keep track of where the utf8 sentinel was found
    var i;

    var charset = options.charset;
    if (options.charsetSentinel) {
        for (i = 0; i < parts.length; ++i) {
            if (parts[i].indexOf('utf8=') === 0) {
                if (parts[i] === charsetSentinel) {
                    charset = 'utf-8';
                } else if (parts[i] === isoSentinel) {
                    charset = 'iso-8859-1';
                }
                skipIndex = i;
                i = parts.length; // The eslint settings do not allow break;
            }
        }
    }

    for (i = 0; i < parts.length; ++i) {
        if (i === skipIndex) {
            continue;
        }
        var part = parts[i];

        var bracketEqualsPos = part.indexOf(']=');
        var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;

        var key, val;
        if (pos === -1) {
            key = options.decoder(part, defaults.decoder, charset);
            val = options.strictNullHandling ? null : '';
        } else {
            key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
            val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
        }

        if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
            val = interpretNumericEntities(val);
        }

        if (val && options.comma && val.indexOf(',') > -1) {
            val = val.split(',');
        }

        if (has.call(obj, key)) {
            obj[key] = utils.combine(obj[key], val);
        } else {
            obj[key] = val;
        }
    }

    return obj;
}
1011086
def p_statement_switch(p):
    ''
    p[0] = ast.Switch(p[3], p[5], lineno=p.lineno(1))
713106
function QueryString (qs) {
        var parts = qs.split('&');

        for (var i = 0, s = parts.length; i < s; i++) {
            var keyVal = parts[i].split('=');
            var key = decodeURIComponent(keyVal[0].replace(RX_PLUS, ' '));

            if (!key) {
                continue;
            }

            var value = keyVal[1] !== undefined ? decode(keyVal[1]) : null;

            if (typeof this[key] === 'undefined') {
                this[key] = value;
            } else {
                if (!(this[key] instanceof Array)) {
                    this[key] = [this[key]];
                }

                this[key].push(value);
            }
        }
    }
720160
function (arr, pred) {
    for (var i = 0; i < arr.length; i++) {
      var value = arr[i];
      if (pred(value, i, arr)) {
        return value;
      }
    }
    return null;
  }
598568
def p_switch_statement(self, p):
        """"""
        # this uses a completely different type that corrects a
        # subtly wrong interpretation of this construct.
        # see: https://github.com/rspivak/slimit/issues/94
        p[0] = self.asttypes.Switch(expr=p[3], case_block=p[5])
        p[0].setpos(p)
        return