<commit_before>var hslToHex = require('tie-dye/hslToHex');

function hashbow(input, saturation, lightness) {

  var toColor, sum;
  saturation = saturation || 100;
  lightness = lightness || 50;

  if (input === null || input === undefined) return hslToHex(0, 0, lightness);

  switch (input.constructor) {
    case Object:
    case Array:
      toColor = JSON.stringify(input);
    break;
    case Number:
      sum = input;
    break;
    case Boolean:
      return hslToHex(input ? 120 : 0, saturation, lightness);
    break;
    case Function:
      toColor = input.toString();
    break;
    case RegExp:
      toColor = input.toString();
    break;
    case String:
    default:
      toColor = input;
  }

  if (sum === undefined) {
    sum = 0;
    toColor.split('').forEach(function (letter) {
      sum += letter.charCodeAt(0);
    });
  }

  sum = Math.abs(sum * sum);

  return hslToHex(sum % 360, saturation, lightness);
}

module.exports = hashbow;
<commit_msg>Refactor switch case statement<commit_after>var hslToHex = require('tie-dye/hslToHex');

function hashbow(input, saturation, lightness) {

  var toColor, sum;
  saturation = saturation || 100;
  lightness = lightness || 50;

  if (input === null || input === undefined) return hslToHex(0, 0, lightness);

  switch (input.constructor) {
    case Function:
    case RegExp:
      toColor = input.toString();
    break;
    case Object:
    case Array:
      toColor = JSON.stringify(input);
    break;
    case Number:
      sum = input;
    break;
    case Boolean:
      return hslToHex(input ? 120 : 0, saturation, lightness);
    break;
    case String:
    default:
      toColor = input;
  }

  if (sum === undefined) {
    sum = 0;
    toColor.split('').forEach(function (letter) {
      sum += letter.charCodeAt(0);
    });
  }

  sum = Math.abs(sum * sum);

  return hslToHex(sum % 360, saturation, lightness);
}

module.exports = hashbow;

{'fraction_non_alphanumeric': 0.13111342351716962, 'fraction_numerical': 0.01664932362122789, 'mean_word_length': 2.823061630218688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '840079', 'n_tokens_mistral': 670, 'n_tokens_neox': 619, 'n_words': 164}